-
Notifications
You must be signed in to change notification settings - Fork 894
feat!: drop reading other 'user' permission #8650
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
f9d2454
feat: drop reading other 'user' permission
Emyrk 89ec2ed
Merge remote-tracking branch 'origin/main' into stevenmasley/drop_rea…
Emyrk 4545d1a
Hide /users page for regular users
Emyrk 7ce87a7
make groups a privledged endpoint
Emyrk 8e86149
Permissions page for template perms
Emyrk 82ceab8
remove console log
Emyrk ddd147d
Fix perms unit tests
Emyrk 658e2e2
Fixing unit tests
Emyrk 9007b8e
make gen
Emyrk 72b0862
Fix pagination users test
Emyrk f1ed8b3
Make fmt
Emyrk 04d9166
Update unit test with perm changes
Emyrk e0af28e
remove unused function
Emyrk 515edf1
count 0 vs -1
Emyrk 39912a2
Unit test to test acl available
Emyrk 4463012
Use correct sdk method
Emyrk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fix pagination users test
- Loading branch information
commit 72b08624e5f7f7eb77a148a486a8bfceb85e7f9b
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should add unit tests in this file to assert this new behaviour.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which new behavior exactly? The rbac stuff is all tested.
I will add a test for the acl availableEDIT: Added for acl available endpointUh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While the RBAC stuff may be unit tested, we also need to ensure that the behaviour is as desired at the API endpoint level.
My understanding of this PR is that it removes the ability of org members to read other org members. Is this understanding correct?
If so, I suggest adding test cases to cover the following:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. You cannot read other org members or other users. This matrix of who can read who is tedious to test at the api level. So I have matrix tests that answer those questions.
Org Member matrix
coder/coderd/rbac/roles_test.go
Lines 290 to 298 in 39912a2
Read user matrix:
coder/coderd/rbac/roles_test.go
Lines 106 to 123 in 39912a2
These cover all the cases you just asked.
The
OrgMember
RBAC object is defined here:coder/coderd/database/modelmethods.go
Lines 194 to 200 in 39912a2
And then it is asserted the db makes the right checks in the
dbauth_test.go
:coder/coderd/database/dbauthz/dbauthz_test.go
Lines 533 to 538 in 39912a2
So these tests cover that any db calls for a given resource as a given actor are correct according to that list you mentioned.
The test I added was the ACL listing available users/groups because it uses
dbauth.AsSystemContext
to get around the permissions and keep the UX if you are an admin for a given template. I imagine we might need to revisit that in future based on certain feedback, but it was required to keep the UX the same.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would also really like to see tests at the coderd package level for this change.
That can be done as a follow-up if required, but it would increase confidence and solidify the behaviour.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would increase confidence for sure.
We don't do these style RBAC tests at the coderd package layer atm except in very few cases. Most of our coderd tests run as☹️ .
Owner
I'd prefer not to have to write all these, because ideally I wouldn't write new tests, but run the existing tests as various actors and assert various outcomes. But that requires refactoring the tests for fetching users, groups, etc 😢.
Essentially, I think if we are going to test these kinds of things at the coderd level, we should do it in a way that doesn't just add a lot of test code bloat.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There might be an issue we should make at some point to audit the rbac assertions in our unit test for correctness.
The current various series of tests are loosely coupled for sure and probably are missing things or have bugs.