Skip to content

Conversation

david-crespo
Copy link
Contributor

@david-crespo david-crespo commented Feb 4, 2025

This came up in a meeting with @davepacheco — storing the roles in the DB and letting them be listed through the API is a legacy idea with no practical application that we know of. When I heard that I was curious how much could be deleted.

Fundamentally, all this machinery I've deleted was just in service of the role_view and role_list endpoints, which let you get something like this list:

fleet     admin
fleet     collaborator
fleet     viewer
silo      admin
silo      collaborator
silo      viewer
project   admin
project   collaborator
project   viewer

I think we thought this would be a dynamic list of roles, but all these things are hard-coded. As far as I can tell there is no relationship to the actual authorization system — this is basically just an unrelated copy of that stuff. This claim borne out by the fact that deleting all this stuff doesn't affect anything else, i.e., doesn't cause any tests to fail.

@david-crespo

This comment was marked as resolved.

Comment on lines -2669 to -2893
* If the set of roles and their permissions are fixed, why store them in the
* database at all? Because what's dynamic is the assignment of roles to users.
* We have a separate table that says "user U has role ROLE on resource
* RESOURCE". How do we represent the ROLE part of this association? We use a
* foreign key into this "role_builtin" table.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't have a strong feeling either way on the PR overall but this note got me thinking: is there value in having this? It'd probably be better if we actually enforced that the (resource_type, role_name) column in role_assignment were a valid foreign key. Given how static this is today, these could as well be enum values instead. 🤷

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I think converting role to an enum would make a lot of sense.

@david-crespo
Copy link
Contributor Author

I've checked this over 10 times and can't see any downside, so I'm going to merge it. Made #8554 as a followup to simplify further by using an enum for the role names.

@david-crespo david-crespo enabled auto-merge (squash) July 8, 2025 21:45
@david-crespo david-crespo merged commit b7b24d5 into main Jul 9, 2025
17 checks passed
@david-crespo david-crespo deleted the delete-builtin-roles branch July 9, 2025 04:30
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