-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Public share middleware & controller #9518
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
Public share middleware & controller #9518
Conversation
| * Show the authentication page | ||
| * The form has to submit to the authenticate method route | ||
| */ | ||
| abstract public function showAuthenticate(string $token): TemplateResponse; |
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.
Shouldn't we have a general showAuthenticate implementation here as well, since most of the time, we will just render a passwort request form.
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.
We could do that sure.. just server it from the core app I guess then.
|
@rullzer The IShareManager is just to be used by files, right? So calendar or other apps still need to implement their own sharing logic. |
|
@juliushaertl that is correct. Ok let me think how to make it more generic then. |
cd160d7 to
a30b48e
Compare
|
@juliushaertl ok abstracted away some more ;) This should work for all types of shares I guess |
|
Ok so it probably should be even further split up. Some controllers just need to know you are properly authenticated (like preview endpoints). If not they will just 404... I'll look into that more next week. |
a30b48e to
f351b9d
Compare
Codecov Report
@@ Coverage Diff @@
## master #9518 +/- ##
============================================
+ Coverage 52.1% 52.12% +0.02%
- Complexity 25910 25946 +36
============================================
Files 1642 1645 +3
Lines 95721 96130 +409
Branches 1289 1373 +84
============================================
+ Hits 49871 50108 +237
- Misses 45850 46021 +171
- Partials 0 1 +1
|
|
@juliushaertl even more splitup now. It is a lot of abstraction and not maybe 100% efficient. But better to have it secure I guess ;) |
f351b9d to
a68d26c
Compare
juliusknorr
left a comment
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.
@rullzer Looks good to me now in terms of separation 👍
- Move basic auth templates to core (so they are default by default as well)
👍
| $token = $this->request->getParam('token'); | ||
| $share = $this->shareManager->getShareByToken($token); | ||
| if ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK | ||
| && !$this->isLinkSharingEnabled()) { |
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.
That check should probably also be in the PublicShareController, right?
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.
mmm good point.
Yeah probably makes sense to not allow any public shares when it is disabled.
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.
Done
| use OCP\Share\IManager as ShareManager; | ||
| use OCP\Share\IShare; | ||
|
|
||
| abstract class FilesPublicShareController extends AuthPublicShareController { |
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.
I think this would probably make more sense to move this to the files_sharing app, since it is limited to be used with the ShareManager. At least I cannot think of how an app would require to use this.
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.
In theory gallery could use it for example. BUt I agree. I'll move it. So the new code we add stays simple. If it turns out we duplicate it again in a lot (>4) places. Then we can think how to unify again.
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.
Done
da5ed84 to
c855295
Compare
|
Failing test is unrelated |
|
@MorrisJobke yes that happens because you go directly to the auth page. So there is no state stored yet. Anyways let me fix that. |
|
@danxuliu ah you are right. Yes the tests need to be updated. |
ed23248 to
ab4939a
Compare
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Now this is in core so the basics (that 99% of the app will want to use) looks always the same. Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
* Removed tests that are now handled by the middleware * Updated tests Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
* They are handled now by the overal sharing public page middleware Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
ab4939a to
5805159
Compare
|
All happy! |
MorrisJobke
left a comment
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.
Tested and works 👍
apps/files_sharing/js/public.js
Outdated
| urlSpec.t = $('#dirToken').val(); | ||
| return OC.generateUrl('/apps/files_sharing/ajax/publicpreview.php?') + $.param(urlSpec); | ||
| var token = $('#dirToken').val(); | ||
| return OC.linkTo('files_sharing', '/publicpreview/'+token) + '?' + OC.buildQueryString(urlSpec); |
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.
Should be OC.generateUrl(OC.linkTo(...)) otherwise index.php prefix isn't added.
juliusknorr
left a comment
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.
Small issue with public previews on my instance, but besides that 👍
apps/files_sharing/js/public.js
Outdated
| } | ||
| else if (previewSupported === 'true') { | ||
| $('#imgframe > video').attr('poster', OC.filePath('files_sharing', 'ajax', 'publicpreview.php') + '?' + OC.buildQueryString(params)); | ||
| $('#imgframe > video').attr('poster', OC.linkTo('files_sharing', '/publicpreview/'+token) + '?' + OC.buildQueryString(params)); |
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.
Should be OC.generateUrl(OC.linkTo(...)) otherwise index.php prefix isn't added.
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Fixes #5986
@juliushaertl as discussed.
Todo:
integrate Do not logout on auth on public share page #9756Once merged: