185 allow organization specific roles #188
Open
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.
Description
This PR adds a
user_roles
table that we will use to provide more granularity to our permissions scheme.The
user_roles
table is associated with both theusers
table and, optionally, theorganizations
table. All users will have an associateduser_roles
.As of this PR the available roles are:
User
- default roleAdmin
- admin within the scope of an organization.SuperAdmin
- global admin.Users with role
Admin
orUser
will have auser_roles
record withrole
Admin
orUser
respectively. theuser_roles
record will be scoped to the organization within which the user has that role.Users with role
SuperAdmin
with have auser_roles
record withrole
SuperAdmin
and will not have anorganization
associated with theiruser_roles
record.Next up
user_roles
records for existing usersGitHub Issue: [Closes|Fixes|Resolves] #185
Changes
user_roles
table via migrationsuper_admin
to enum typerole
user_roles
entityTesting Strategy
rebuilding the db:
roll back migration
re-apply migration
Concerns
The migration is written mostly in Raw SQL. I opted for this as seaORM's documentation around migrations is still very lacking in actual usable examples. The main drawback here is portability between postgres and other database products should we ever want to switch. It's highly unlikely that that will ever happen.