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

Sharing: Do not show copy action when user doesn't have permissions #37802

Merged
merged 2 commits into from
May 3, 2023

Conversation

marcelklehr
Copy link
Member

@marcelklehr marcelklehr commented Apr 18, 2023

fixes #37729

Screencasts

Before
Peek 2023-04-18 18-20

After
Peek 2023-04-18 18-18

Checklist

@szaimen szaimen added the 3. to review Waiting for reviews label Apr 18, 2023
@szaimen szaimen added this to the Nextcloud 27 milestone Apr 18, 2023
Copy link
Contributor

@artonge artonge left a comment

Choose a reason for hiding this comment

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

Shouldn't the user be allowed to copy a file if he can read it?

@marcelklehr
Copy link
Member Author

Shouldn't the user be allowed to copy a file if he can read it?

In the end it's a philosophical question, I guess. Currently, the back-end does not allow this and Jan opined in the relevant ticket, that we should hide the option.

cc @jancborchardt

@artonge
Copy link
Contributor

artonge commented Apr 19, 2023

No, it is rather technical. If I can read the file, then copying is possible, either by copy-pasting, or if the software allows it, with one click.

I also just check and Nautilus is allowing copying read-only files. Same with bash.

@marcelklehr
Copy link
Member Author

No, it is rather technical.

I agree, this is the technical perspective. There is a UX perspective to this in a way. But personally, I'm very unconcerned by which way this goes. Either we fix this in the UI and don't show the option, or we fix it in the backend to make it possible to copy files when the user has read permissions. I'll let you fight this out with @jancborchardt

@skjnldsv
Copy link
Member

or we fix it in the backend to make it possible to copy files when the user has read permissions. I'll let you fight this out with @jancborchardt

I think this is the way to go as this is what I would expect from a dav endpoint.
The question here is where does it fail? When you copy, does it fail on the READ check, or on the WRITE permission of the destination folder?

@marcelklehr
Copy link
Member Author

Seems like the permission error stems from here: https://github.com/nextcloud/server/blob/master/apps/dav/lib/DAV/ViewOnlyPlugin.php

@jancborchardt
Copy link
Member

Sorry, I assumed the backend was as intended. If not, then I would agree that this is rather something to fix in the backend. :)

@skjnldsv skjnldsv added 2. developing Work in progress and removed 3. to review Waiting for reviews labels Apr 27, 2023
@skjnldsv skjnldsv removed their request for review April 27, 2023 05:43
@marcelklehr marcelklehr changed the title fix(files/fileactions.js): Do not show copy action when user doesn't … Sharing: Do not show copy action when user doesn't have permissions Apr 28, 2023
@@ -94,7 +94,7 @@ import { getCapabilities } from '@nextcloud/capabilities'
}
if (_.isFunction(fileData.canDownload) && !fileData.canDownload()) {
delete fileActions.actions.all.Download
if (fileData.permissions & OC.PERMISSION_UPDATE === 0) {
if ((fileData.permissions & OC.PERMISSION_UPDATE) === 0) {
Copy link
Member Author

Choose a reason for hiding this comment

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

> (1 & 2 === 0)
0
> (1 & 2) === 0
true

😡

Copy link
Contributor

Choose a reason for hiding this comment

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

I always feel we do not put enough parenthesis in Nextcloud code, I tend to be paranoid about these things. There are so many operators it’s too hard to remember all priorities by heart.

@marcelklehr
Copy link
Member Author

/rebase

@marcelklehr marcelklehr added 3. to review Waiting for reviews and removed 2. developing Work in progress labels Apr 28, 2023
@marcelklehr
Copy link
Member Author

It turns out, there was already code for this, but it didn't work.

@marcelklehr
Copy link
Member Author

Citing @jancborchardt

Ok, then we go ahead as previously discussed and implemented in your PR, that is when Download is disabled, "Copy" is removed? Cause since we have this specific download restriction, the intention on the sharer’s side is clearly to prevent it spreading.


I can haz reviews?

@marcelklehr
Copy link
Member Author

/rebase

@marcelklehr
Copy link
Member Author

/compile

Signed-off-by: nextcloud-command <[email protected]>
@skjnldsv skjnldsv mentioned this pull request May 3, 2023
@marcelklehr marcelklehr merged commit 545de25 into master May 3, 2023
@marcelklehr marcelklehr deleted the fix/37729 branch May 3, 2023 08:57
@marcelklehr
Copy link
Member Author

/backport to stable26

@marcelklehr
Copy link
Member Author

/backport to stable25

@backportbot-nextcloud
Copy link

The backport to stable25 failed. Please do this backport manually.

# Switch to the target branch and update it
git checkout stable25
git pull origin/stable25

# Create the new backport branch
git checkout -b fix/foo-stable25

# Cherry pick the change from the commit sha1 of the change against the default branch
# This might cause conflicts. Resolve them.
git cherry-pick abc123

# Push the cherry pick commit to the remote repository and open a pull request
git push origin fix/foo-stable25

More info at https://docs.nextcloud.com/server/latest/developer_manual/getting_started/development_process.html#manual-backport

@backportbot-nextcloud
Copy link

The backport to stable26 failed. Please do this backport manually.

# Switch to the target branch and update it
git checkout stable26
git pull origin/stable26

# Create the new backport branch
git checkout -b fix/foo-stable26

# Cherry pick the change from the commit sha1 of the change against the default branch
# This might cause conflicts. Resolve them.
git cherry-pick abc123

# Push the cherry pick commit to the remote repository and open a pull request
git push origin fix/foo-stable26

More info at https://docs.nextcloud.com/server/latest/developer_manual/getting_started/development_process.html#manual-backport

@marcelklehr
Copy link
Member Author

/backport af66537 to stable25

@marcelklehr
Copy link
Member Author

/backport af66537 to stable26

@solracsf
Copy link
Member

solracsf commented Jun 7, 2023

/backport to stable27

@backportbot-nextcloud
Copy link

The backport to stable27 failed. Please do this backport manually.

# Switch to the target branch and update it
git checkout stable27
git pull origin/stable27

# Create the new backport branch
git checkout -b fix/foo-stable27

# Cherry pick the change from the commit sha1 of the change against the default branch
# This might cause conflicts. Resolve them.
git cherry-pick abc123

# Push the cherry pick commit to the remote repository and open a pull request
git push origin fix/foo-stable27

More info at https://docs.nextcloud.com/server/latest/developer_manual/getting_started/development_process.html#manual-backport

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.

[Bug]: File copy action is visible even though user doesn't have permission
8 participants