Repository navigation
Feature share link with token - #380
Conversation
|
What is the intention of using the alphaID() function? |
|
alphaID() can be used to map numeric ids to a short alphanumeric string. I was first thinking of using it to generate the token from the share id but then I realized that then the token would not be random and could not be used as a pseudo password. I still like the way the token is generated because is uses a lot of characters but If there is already code in OC that generates tokens I'll use that. |
|
|
I think I updated everything with the exception of the uid owner not being the actual owner ... any ideas how to do this in a clean way? |
|
@MTGap @LukasReschke @DeepDiver1975 @karlitschek @tanghus I think this should do it. Please test and give it your thumbs up! |
|
Everything seems to work and it fixes issue #382. The patch didn't apply cleanly for me, there was an issue with the db update. I think there was another update in master to it. You still have the TOKEN_LENGTH constant in the code. After that :+1 What is our standard for pull requests is it alright that there are multiple commits that undo previous commits? |
That was me. I bumped the version last night. Sorry.
If you merge it while @DeepDiver1975 is asleep ;) You should bump version to (4, 91, 02) |
|
We should keep the individual commits if possible .. but the fixes removed a lot of code and my git rewrite foo was not as god as I had hoped, so I just squashed them into one commit. The TOKEN_LENGTH is used to prevent a magic number in the call of generate_random_bytes. Also increased the version to (4, 91, 02) |
|
@karlitschek. I have the backport ready for stable45 but will wait for this to be pulled before committing it |
|
tested 👍 |
|
I just tried it especially with respect to issue #117
Another issue: The sharing drop down shows "null" as token for public links created before I applied the patch. I also can't remove the link and create a new one because removing the broken link results in a error message. I think we need a update routine which transfer old share links to the new ones. It is probably enough to just generate all missing tokens in the database during the first run. |
|
Can you provide an example of resulting shared file / directory URLs? |
|
after this pull request the produced share links look like this the hash could be shortened but that should be done in another pull request |
|
@schiesbn Could you retest the issue with sharing a directory from a shared folder? null links should now be replaced by old pre token links. |
|
@butonic I still get a "cloud not found" in some situations. Let me give you an example:
I only had a short look at your code, but i think the problem is most likely that you use the function getID() in apps/files_sharing/public.php to find the file cache ID of the given folder. But this only works for the root folder ("demo" in the example above) because all the folders below the root folder are not stored in oc_share. On stable45 I use the function getSourcePath() in apps/files_sharing/lib/util.php to get the real path of a file/folder stored somewhere in the shared folder. The same functions are also available in apps/files_sharing/lib/sharedstorage.php but marked as private. For stable45 I copied them to util.php to be able to use them outside of OC_Filestorage_Shared to find shared files, e.g. on the webdav back-end. Maybe this is useful for you to resolve the issue. |
|
Regarding the fallback mode for pre-token links. I would prefer to increase the version number of the files_sharing app and update the update script to add a token to all link-shares. This would avoid the overhead to maintain the fallback code. |
|
@schiesbn I cannot reproduce the example you described. Are you using token based links? Has the folder previously been shared with a dil/dir based link? Could you try with a clean database? Are you using ldap (although I don't think it has anything to do with the issue)? |
|
@butonic I just tried it with an empty database. The problem only appears if user2 creates a folder/file in a shared folder. So the right example is:
|
|
@butonic I found the problem and fixed it in pull request 581. The problem was that we added the user who created the file as file owner to the file cache and not the actual owner. This should fix the issue but I didn't test it until now together with your version |
|
since the isses reported by @schiesbn are fixed in #581 and a fallback for old links has been implemented I'll merge this. |
To make reviewing easier I separated the changes into smaller commits with a - hopefully - meaningful commit message.
I plan to refactor some of the sharing code and add authorization mechanisms for shares by contacts and email. But let's first get this into core :)
@MTGap Please have a look at OCP\Share::getShareByToken($token) which I added to retrieve the share item. I admit that I bypass any magic in getItem(...) and cannot see whether that is a problem for other use cases like sharing a contact or an event ...
related to #105