Repository navigation
docs: propose custom_role and principal_group schema for [ADR6 (BDMS-1557)] - #1047
Conversation
Coverage✅ 81.81% total — gate is 75%. |
Review:
|
TylerAdamMartinez
left a comment
There was a problem hiding this comment.
Overall, looks great!
|
|
||
| ## Principal group schema | ||
|
|
||
| **`principal_group`** (proposed name) -- the group's identity: |
There was a problem hiding this comment.
I don't think we need to mention "(proposed name)" in this document, since if this PR is approved, those will be the official names.
| | principal_group_id | member_id | added_by | | ||
| |---|---|---| | ||
| | 1 | auth0\|sub-kelsey | jake | | ||
| | 1 | auth0\|sub-tyler | jake | |
jacob-a-brown
left a comment
There was a problem hiding this comment.
Overall I think that it looks good! Just some small comments.
I also think that, for the sake of being explicit, the schemas in ##Principal group schema should include the data types. It's pretty obvious from reading the tables, but since this defines the schemas the data types should be defined too.
To answer open questions:
- I think that
principal_groupis a good table name. - I think that
principal_group_memberis a good table name. I don't know ifmember_idneeds more than the bare sub since we can use that to identify the individual (?). What if it's an API key, though? Does that have an id that can get assigned to that field? - I think that group assignment needs delegation boundaries once the schema is settled.
- I'm okay to keep ADR6's log table. Wouldn't we be able to query that to determine changes and who was present when? Creating something akin to
StatusHistoryseems like a lot of work for what we may be able to achieve by querying the table proposed by ADR6.
| | `created_by` | Who created it | | ||
| | `created_at` | When | | ||
|
|
||
| **`principal_group_member`** -- its membership, one row per person: |
There was a problem hiding this comment.
this is a many-to-many table? A table that relates a principal to a principal_group? If so that should be written out here
| | Column | Meaning | | ||
| |---|---| | ||
| | `principal_group_id` | FK to `principal_group.id` | | ||
| | `member_id` | The Authentik-issued `sub` identifying the person | |
There was a problem hiding this comment.
previously we we were identifying people/keys as principals. Should this be called principal_id?
There was a problem hiding this comment.
For now I'd like to keep this as member_id rather than principal_id. It reads more clearly for what the column actually is (one person in this specific group), and it's not quite the same thing as permission_grant.principal_id, which can be a user, api, or a principal_group itself. If it turns out principal_id is the better name , happy to switch it .
|
|
||
| | Column | Meaning | | ||
| |---|---| | ||
| | `principal_group_id` | FK to `principal_group.id` | |
There was a problem hiding this comment.
Consider id as the primary key instead of principal_group_id. The table name is typically included when referenced or called, so principal_group_member.id would be used instead of principal_group_member.principal_group_id. id is also used as the PK on most of the current tables, so we'd be keeping it consistent.
There was a problem hiding this comment.
Agreed, updated. principal_group_member now has its own id as primary key
ksmuczynski
left a comment
There was a problem hiding this comment.
Responses to open questions:
principal_groupworks as the table name.principal_group_memberworks as the table name. I'm not sure if we need a separate user table to display name/email per member. Maybe we keep as is and modify later if we receive feedback regarding the need for additional user information?- I think we can figure group assignment boundaries later.
- Similar to question 2, maybe proceed with ADR 6's activity log and we could consider something more detailed if needed.
Why
This PR addresses the following problem / context:
How
Implementation summary: the following was changed / added / removed:
docs/permission-bundle-and-group-membership-schema.md, proposing:principal_group/principal_group_memberfor group identity and membership,custom_role/custom_role_itemfor the permission bundle, and a new nullablecustom_role_idonpermission_grantfor direct-grant vs. role-assignment rows.custom_rolewas chosen over plainrole(collision with the existingRolelexicon/enum).user/api_keydirectly, delegation boundaries, and whether a principal can hold multiple assignments.Author Checklist
Reviewer Checklist
custom_rolecan be assigned touser/api_keydirectly, or only to aprincipal_group(Open Question 6).Notes
Any special considerations, known limitations, risks, workarounds, or follow-up work to note?