Skip to content
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

[full-ci] Allow no permissions on Links #2687

Merged
merged 16 commits into from
Apr 4, 2022
Merged

Conversation

kobergj
Copy link
Contributor

@kobergj kobergj commented Mar 28, 2022

Adds an endpoint to ocs service that exposes information about link tokens.
Usage:

curling the unprotected endpoint returns standard information

curl --insecure -X GET https://localhost:9200/ocs/v1.php/apps/files_sharing/api/v1/tokeninfo/unprotected/jqDCLhaiyIvXZTp

<TokenInfo>
  <token>jqDCLhaiyIvXZTp</token>
  <linkurl>/s/jqDCLhaiyIvXZTp</linkurl>
  <passwordprotected>false</passwordprotected>
  <storageid>f7fbf8c8-139b-4376-b307-cf0a8c2d0d9c</storageid>
  <opaqueid>c6378f93-0e2d-4f77-812b-a1b2b3ee04ae</opaqueid>
  <path/>
  <spacePath/>
  <spaceAlias/>
  <spaceURL/>
</TokenInfo>

curling a password protected link only returns minimal information

curl --insecure -X GET https://localhost:9200/ocs/v1.php/apps/files_sharing/api/v1/tokeninfo/unprotected/jqDCLhaiyIvXZTp

<TokenInfo>
  <token>jqDCLhaiyIvXZTp</token>
  <linkurl>/s/jqDCLhaiyIvXZTp</linkurl>
  <passwordprotected>true</passwordprotected>
  <storageid/>
  <opaqueid/>
  <path/>
  <spacePath/>
  <spaceAlias/>
  <spaceURL/>
</TokenInfo>

curling the protected endpoint returns full information if user has native access

curl --insecure -X GET https://localhost:9200/ocs/v1.php/apps/files_sharing/api/v1/tokeninfo/protected/jqDCLhaiyIvXZTp -u marie:radioactivity

<TokenInfo>
  <token>jqDCLhaiyIvXZTp</token>
  <linkurl>/s/jqDCLhaiyIvXZTp</linkurl>
  <passwordprotected>false</passwordprotected>
  <storageid>f7fbf8c8-139b-4376-b307-cf0a8c2d0d9c</storageid>
  <opaqueid>c6378f93-0e2d-4f77-812b-a1b2b3ee04ae</opaqueid>
  <path/>
  <spacePath>/users/f7fbf8c8-139b-4376-b307-cf0a8c2d0d9c</spacePath>
  <spaceAlias>personal/marie</spaceAlias>
  <spaceURL>personal/marie/c6378f93-0e2d-4f77-812b-a1b2b3ee04ae</spaceURL>
</TokenInfo>

curling the protected endpoint returns same information as unprotected endpoint if user does not have native access

curl --insecure -X GET https://localhost:9200/ocs/v1.php/apps/files_sharing/api/v1/tokeninfo/protected/jqDCLhaiyIvXZTp -u einstein:relativity

<TokenInfo>
  <token>jqDCLhaiyIvXZTp</token>
  <linkurl>/s/jqDCLhaiyIvXZTp</linkurl>
  <passwordprotected>false</passwordprotected>
  <storageid>f7fbf8c8-139b-4376-b307-cf0a8c2d0d9c</storageid>
  <opaqueid>c6378f93-0e2d-4f77-812b-a1b2b3ee04ae</opaqueid>
  <path/>
  <spacePath/>
  <spaceAlias/>
  <spaceURL/>
</TokenInfo>

curling the protected endpoint without authentication returns 401 Unauthorized

curl --insecure -X GET https://localhost:9200/ocs/v1.php/apps/files_sharing/api/v1/tokeninfo/protected/jqDCLhaiyIvXZTp

HTTP/1.1 401 Unauthorized

@lgtm-com
Copy link

lgtm-com bot commented Mar 30, 2022

This pull request introduces 1 alert when merging f3aed1b into fe9a8c2 - view on LGTM.com

new alerts:

  • 1 for Useless assignment to local variable

Signed-off-by: jkoberg <[email protected]>
@kobergj kobergj marked this pull request as ready for review March 31, 2022 14:50
@kobergj kobergj requested review from a team, labkode, ishank011 and glpatcern as code owners March 31, 2022 14:50
@kobergj kobergj changed the title [tests-only] Allow no permissions on Links [full-ci] Allow no permissions on Links Mar 31, 2022
@butonic
Copy link
Contributor

butonic commented Apr 1, 2022

why does it make sense to have two endpoints? when should clients use /dav/tokeninfo/unprotected/{token} and when /dav/tokeninfo/protected/{token}? why is a single /dav/tokeninfo/{token} endpoint not sufficient?

@kobergj
Copy link
Contributor Author

kobergj commented Apr 1, 2022

@butonic Clients should use the protected endpoint when they have an authenticated user already. The unprotected endpoint is used when there is no user logged in yet.

Of course this could also be done in one endpoint. But then we would need to duplicate authentication logic from the auth interceptor. By using different endpoints the auth middleware can take care of authentication, and future refactorings can be done in auth middleware only.

IMO it was the simplest and stablest approach to use two endpoints and reuse existing code.

@butonic
Copy link
Contributor

butonic commented Apr 1, 2022

could you move this to the ocs service instead of ocdav. this is not really webdav and being able to query this information as json is a lot nicer for the web clients.

Signed-off-by: jkoberg <[email protected]>
@kobergj
Copy link
Contributor Author

kobergj commented Apr 1, 2022

@butonic I moved the handler to ocs. Please recheck!

@kobergj kobergj requested a review from butonic April 1, 2022 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants