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

refactor: remove share role checks #11364

Merged
merged 3 commits into from
Aug 23, 2024
Merged

Conversation

JammingBen
Copy link
Contributor

@JammingBen JammingBen commented Aug 15, 2024

Description

Use share permissions instead of roles since roles are a very loose concept and just act as a container for a specific set of share permissions.

This affects 2 main scenarios:

  • A SpaceResource doesn't have properties like manager, editor anymore. The same goes for methods like isManager. Instead, there is the members property that holds information about all members. When checking if the current user is allowed to do certain actions, we need check for specific permissions now. E.g. when sharing, don't check for isManager but for canShare.
  • Shares (in Graph terms: "permissions") will also have permissions (in Graph terms: "permission actions") that need to be checked instead of roles. Hence the GraphShareRoleIdMap is being removed.

You may notice a discrepancy in our naming and the Graph naming. IMO we should align... but that's a another story, I guess. Because ideally, I would also rename Space to Drive. It's just so confusing all the time.

There is one exception where Web still needs to assume and work with roles. That is when listing the managers of a space. Here we imply that if the user can remove space members, they are a space manager.

Related Issue

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Technical debt
  • Tests
  • Documentation
  • Maintenance (e.g. dependency updates or tooling)

@JammingBen JammingBen self-assigned this Aug 15, 2024
Copy link

update-docs bot commented Aug 15, 2024

Thanks for opening this pull request! The maintainers of this repository would appreciate it if you would create a changelog item based on your changes.

@JammingBen JammingBen force-pushed the refactor/remove-share-role-checks branch 3 times, most recently from 463fa2e to aa657fc Compare August 15, 2024 13:51
@fschade fschade mentioned this pull request Aug 16, 2024
9 tasks
@JammingBen JammingBen force-pushed the refactor/remove-share-role-checks branch 5 times, most recently from ed9d7ae to 1401f72 Compare August 21, 2024 08:04
@JammingBen JammingBen force-pushed the refactor/remove-share-role-checks branch 3 times, most recently from 21cb63f to 0c76d43 Compare August 21, 2024 11:36
Comment on lines -76 to -79
if (resources[0].disabled) {
return false
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is already being checked in canEditReadme.

@JammingBen JammingBen force-pushed the refactor/remove-share-role-checks branch 2 times, most recently from 7b965f0 to ad41acc Compare August 21, 2024 12:52
@JammingBen JammingBen force-pushed the refactor/remove-share-role-checks branch 5 times, most recently from 0bc1c92 to 136c7e7 Compare August 21, 2024 14:38
@JammingBen JammingBen force-pushed the refactor/remove-share-role-checks branch from 136c7e7 to 58f0563 Compare August 22, 2024 06:22
@JammingBen JammingBen marked this pull request as ready for review August 22, 2024 07:47
canDownload: () =>
sharePermissions.includes(GraphSharePermission.readBasic) &&
!shareRoles.some((shareRole) => shareRole.id === GraphShareRoleIdMap.SecureViewer),
canDownload: () => sharePermissions.includes(GraphSharePermission.readContent),
Copy link
Member

Choose a reason for hiding this comment

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

So do I get it right that readContent permission action is not given with a secure view share? Which permission action does the secure view share have for secure-viewing content?

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 need to check, not sure if there are any permissions 😅

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay so the permissions of a secure view share are these:

* libre.graph/driveItem/path/read
* libre.graph/driveItem/children/read
* libre.graph/driveItem/basic/read

Copy link
Member

@kulmann kulmann left a comment

Choose a reason for hiding this comment

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

Thank you for this! I can imagine that it has been a tedious chunk of work. 🤗

Copy link

@JammingBen JammingBen merged commit 804979e into master Aug 23, 2024
3 checks passed
@kulmann kulmann deleted the refactor/remove-share-role-checks branch September 5, 2024 19:47
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.

2 participants