-
Notifications
You must be signed in to change notification settings - Fork 937
feat: Add user roles, but do not yet enforce them #1200
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 all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
9d531cb
WIP
Emyrk 1eabb07
chore: Rework roles to be expandable by name alone
Emyrk dc6010b
Add role migrations
Emyrk af7fcf1
Make gen
Emyrk 5d47865
Add admin role to the first user
Emyrk d8a5ba1
Implement builtin roles
Emyrk e8b2e33
Add fake for GrantRoles
Emyrk eae626c
Correct indentation on sql
Emyrk 5aba5a2
Add endpoints to grant new roles to a user
Emyrk 5b902de
Make gen after rebase
Emyrk 7a32c38
re insert code lost in merge
Emyrk 3b18317
Appease the linter
Emyrk 8316deb
Make gen
Emyrk 7d03554
Audit log track rbac_roles
Emyrk b732d03
PR comments
Emyrk 4da2c4f
Merge remote-tracking branch 'origin/main' into stevenmasley/user_ass…
Emyrk a77d535
Add orgids to user response
Emyrk 32f5dc0
Rename type to use proper casing
Emyrk 2c33a82
feat: Split org/site roles
Emyrk 0e3fc29
Add more unit testing
Emyrk 9d47b74
Update comment
Emyrk 96fb498
Merge remote-tracking branch 'origin/main' into stevenmasley/user_ass…
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
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
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ALTER TABLE ONLY users | ||
DROP COLUMN IF EXISTS rbac_roles; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
ALTER TABLE ONLY users | ||
ADD COLUMN IF NOT EXISTS rbac_roles text[] DEFAULT '{}' NOT NULL; | ||
|
||
-- All users are site members. So give them the standard role. | ||
-- Also give them membership to the first org we retrieve. We should only have | ||
-- 1 organization at this point in the product. | ||
UPDATE | ||
users | ||
SET | ||
rbac_roles = ARRAY ['member', 'organization-member:' || (SELECT id FROM organizations LIMIT 1)]; | ||
|
||
-- Give the first user created the admin role | ||
UPDATE | ||
users | ||
SET | ||
rbac_roles = rbac_roles || ARRAY ['admin'] | ||
WHERE | ||
id = (SELECT id FROM users ORDER BY created_at ASC LIMIT 1) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
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.
TIL postgres supports native text arrays 😄