-
-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix viewer in public albums #1602
Conversation
@starypatyk thanks a lot, I'll test in a bit! I noticed that also in "regularly" shared albums there is an issue whenever trying to open a photo from another user in the viewer, also seems related to a wrong endpoint. #1440 ...and one more: the deletion in Viewer has a wrong path: #1591 Any chances these are also related to the same auth mixup? |
Thanks! 👍
Most likely these are unrelated. My changes are relevant only for public albums. |
Works like a charm for me, now clicking on thumbnails in a publicly shared album correctly opens the image in the viewer. Also downloading the original from there works. When removing the public share and accessing the file DAV endpoint, i.e. Shouldn't this just be a HTTP error code? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right now there is no bruteforce checking anymore, right? So even if an album link does not lead to a correct album returned this is not registered.
Could we add this back?
I think that this is the content that gets returned together with 404 error code. Apparently the output depends on the request - most likely based on the Accept header. When invoking an invalid URL with Curl I get (simplified for clarity):
|
Indeed - I have removed it. Some thoughts:
|
Alright then. :) I now realize I get the same return also for regularly shared files. 👍
That's right, just not sure if it might reduce resource usage if we throttle early instead of querying the DB for every supposed album. But I really have no clue 😄 |
Me neither... 😉 I have not yet figured out how the throttling works. Can try to add it back if suggested. |
I think having brute force protection on share endpoints would be good. here's the docs on that https://docs.nextcloud.com/server/latest/developer_manual/basics/controllers.html#brute-force-protection |
I have aligned the changes in I had to revert setting the This would need to be discussed further, if we would like to have this workaround available for currently released and older versions of the Viewer app. |
After nextcloud/viewer@4a080e4 the |
fix in viewer was merged and backported |
In 8d5572b I have put brute force throttling back. As this needs to protect WebDAV requests, this seemed to me like a reasonable place. This is very similar to the implementation here: But I am not satisfied with the result. 😞 I have tried to open an invalid URL a few times and the throttling turned on very quickly - I started to get significant delays (10 seconds or more). Unfortunately, this continued even when I finally used a correct URL. I imagine this might easily happen for regular users - in situations like missing last character when copying a link, someone enabling/disabling sharing of the same album, etc. Might be reasonable to change the throttling parameters to make it less intrusive. Or maybe resetting throttling when the user provides a correct link. Thoughts/suggestions? |
@starypatyk can you check whether you can implement throttling as suggested by the doc ? https://docs.nextcloud.com/server/latest/developer_manual/basics/controllers.html#rate-limiting |
I have looked at the code in TL;DR - I would suggest not to implement either of these mechanisms for public albums. Here is my reasoning:
If you agree with this, I will revert the last commit: 8d5572b It is possible to implement a more advanced rate limiter that would also introduce a delay and hopefully reduce the server load. But this seems to be a topic for another PR - likely in the core server code. 😉 |
Signed-off-by: Dariusz Olszewski <[email protected]>
Signed-off-by: Dariusz Olszewski <[email protected]>
Signed-off-by: Dariusz Olszewski <[email protected]>
Signed-off-by: Dariusz Olszewski <[email protected]>
Signed-off-by: Dariusz Olszewski <[email protected]>
Signed-off-by: Dariusz Olszewski <[email protected]>
Co-authored-by: Louis <[email protected]> Signed-off-by: Dariusz Olszewski <[email protected]>
4c87d25
to
876bdf7
Compare
Rebased |
/backport to stable25 |
@artonge is cypress failure related? |
I don't think so. Let's rerun, we'll see |
Thanks a lot @starypatyk for fixing this and @simonspa for the help and @artonge for reviews! :) |
@szaimen @artonge @marcelklehr Just one thing - I have not reverted the brute force throttling introduced in commit 7922c69 as discussed in the comment above: #1602 (comment), as I was not sure if it is OK to do so. Should I submit a separate PR to discuss this? |
I think it is better to keep it for now. |
This is an attempt to fix #1452 (and related duplicates). It consists of two related changes.
Also fix #1440
Part 1 - commit 1d1f011
If I understand correctly, the WebDAV requests to
/remote.php/dav/photospublic/album-token/id-filename
are supposed to be available anonymously - for everyone who has a link to the album, without a need to authenticate first.The
Sabre\DAV\Auth\Backend\AbstractBasic
class expects theAuthorization: Basic
header, and returns 401 error code if it is not present:https://github.com/sabre-io/dav/blob/master/lib/DAV/Auth/Backend/AbstractBasic.php#L101
I think that in this case we should just allow anonymous access - by implementing the
Sabre\DAV\Auth\Backend\BackendInterface
interface directly. ThePublicAlbumAuthBackend
class is registered only for DAV URLs starting withphotospublic
, so it seems safe to always report success in thecheck
method.See: https://github.com/nextcloud/photos/blob/master/lib/Listener/SabrePluginAuthInitListener.php#L47
Part 2 - commit 166c635
I propose two changes in
PublicAlbumContent.vue
:hasPreview
tofalse
for all files in the album. This will force current implementation in the Viewer app to use the source URL, rather than the default preview URL that does not work in this case. These changes alone should suffice to fix the issue - at least temporarily.appPreviewPath
- is a proposal how the app can provide a custom preview URL to the Viewer app. This is obviously not yet handled - I plan to submit a complementary PR to the Viewer app.Comments/suggestions?