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

fix(files_sharing): Respect permissions passed when creating link shares #50270

Merged
merged 3 commits into from
Jan 28, 2025

Conversation

susnux
Copy link
Contributor

@susnux susnux commented Jan 20, 2025

Summary

Given:

  • User creates a link or email share with permissions=4 (create only = file drop).

Problem:

  • Currently the permissions are automatically extended to permissions = 5 (READ + CREATE).
  • Workaround was to create the share and directly update it.

Solution:

  • Respect what the user is requesting, create a file drop share.

Checklist

@susnux susnux added this to the Nextcloud 31 milestone Jan 20, 2025
@susnux
Copy link
Contributor Author

susnux commented Jan 20, 2025

/backport to stable30

@Altahrim Altahrim mentioned this pull request Jan 21, 2025
@susnux susnux requested a review from come-nc January 21, 2025 08:26
@susnux susnux force-pushed the fix/share-api-create--permissions branch 7 times, most recently from 8476ff3 to 8283538 Compare January 22, 2025 18:35
@susnux susnux requested a review from come-nc January 22, 2025 18:35
@Altahrim Altahrim mentioned this pull request Jan 23, 2025
@susnux
Copy link
Contributor Author

susnux commented Jan 24, 2025

/backport to stable31

@susnux
Copy link
Contributor Author

susnux commented Jan 24, 2025

/backport to stable29

Copy link
Member

@provokateurin provokateurin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found it a bit hard to follow all the changes in the first commit, maybe you can split such big refactorings into multiple atomic commits that are easier to review.
Other than that this LGTM, just one minor comment.

if ($permissions === null) {
if ($shareType === IShare::TYPE_LINK
|| $shareType === IShare::TYPE_EMAIL) {
assert($this->userId !== null);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we really use assertions?
In theory we know that the userid is not null, but we should still check.
Assertions can be disabled, so idk if it's the best to check this way.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we already do so would consider this a living standard. But yes could improve - but again this would mean our middleware is broken 🙈

@susnux susnux force-pushed the fix/share-api-create--permissions branch from b00f992 to 1b560ea Compare January 28, 2025 15:29
susnux and others added 3 commits January 28, 2025 16:40
Given:
User creates a link or email share with permissions=4 (create only = file drop).

Problem:
Currently the permissions are automatically extended to permissions = 5
(READ + CREATE). Work around was to create the share and directly update
it.

Solution:
Respect what the user is requesting, create a file drop share.

Co-authored-by: Ferdinand Thiessen <[email protected]>
Co-authored-by: Côme Chilliet <[email protected]>
Signed-off-by: Ferdinand Thiessen <[email protected]>
@susnux
Copy link
Contributor Author

susnux commented Jan 31, 2025

/backport to stable28

@susnux
Copy link
Contributor Author

susnux commented Jan 31, 2025

/backport to stable27

@susnux
Copy link
Contributor Author

susnux commented Jan 31, 2025

/backport to stable26

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create Share API not honoring "permissions" parameter
3 participants