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

Ignore Resharing instead of Erroring #4816

Merged
merged 1 commit into from
Aug 23, 2024

Conversation

kobergj
Copy link
Contributor

@kobergj kobergj commented Aug 20, 2024

Ignores resharing. See owncloud/ocis#9681

Also changes the default from Manager to Viewer as Manager would result in a bad request.

@kobergj kobergj requested review from labkode, a team and glpatcern as code owners August 20, 2024 14:18
Comment on lines 285 to 309
// NOTE: clients tend to send "31" as permissions but they mean "15". "31" is no longer allowed as we have no resharing any more.
if reqRole == "" && reqPermissions == "31" {
reqPermissions = "15"
}

// user collaborations default to Manager (=all permissions). This will result in a BadRequest. Sane Default.
Copy link

@ScharfViktor ScharfViktor Aug 20, 2024

Choose a reason for hiding this comment

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

then we need to adapt the test. https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiReshare/resharing.feature#L108-L156

I see that you have done a workaround for only one case (31 permissions)
If the client sends another permission containing 16 (resharing) -> we get the same result as before

Copy link

@ScharfViktor ScharfViktor Aug 20, 2024

Choose a reason for hiding this comment

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

as suggestion

if reqRole == "" && permissions > 16 {
		permissions -= 16
	}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I forwarded the question. I'd go for the simplest fix possible. This is a hack on a deprecated API anyways.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

as suggestion

if reqRole == "" && permissions > 16 {
  	permissions -= 16
}

That doesn't work unfortunately. permissions is a string. It would need to be an int to support substraction.

// Or we could change the role later and hope everything works out.
// Or:
if reqRole == "" {
switch reqPermissions {
Copy link
Contributor

Choose a reason for hiding this comment

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

The permission bits are:
https://doc.owncloud.com/server/next/admin_manual/configuration/files/file_sharing_configuration.html#permissions-masks

1 - read
2 - update
4 - create
8 - delete
16 - share (no longer used on ocis)

I suppose that someone could be granted 1+8+16=25 (read, delete and share) and that should become 9.

And for "file drop" there can be combinations like update+create=6 (the person doing the "file drop" cannot read back the file after "dropping" it), and maybe some client might send 22 as the permissions?

Why not just "cast to int" then take the remainder mod16, and cast back to string. That avoids thinking about which permission bit combinations will actually happen.

Copy link
Contributor Author

@kobergj kobergj Aug 21, 2024

Choose a reason for hiding this comment

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

This is a deprecated endpoint. Additionally I hope that his gets fixed in clients so we can remove it here. It doesn't need to be very resilient, only needs to fix the actual problem. In fact, it would already be enough to only handle "17", "25" and "31". I just added the other values so it matches with the tests. I don't think we need any more values as there will not be any feature updates to this endpoint

Copy link
Contributor

Choose a reason for hiding this comment

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

FYI, @TheOneRing, ok for you?

Signed-off-by: jkoberg <jkoberg@owncloud.com>
@kobergj kobergj merged commit ff4b71b into cs3org:edge Aug 23, 2024
9 of 10 checks passed
@kobergj kobergj deleted the IgnoreResharingRequests branch August 23, 2024 07:49
@micbar micbar mentioned this pull request Sep 12, 2024
18 tasks
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.

5 participants