-
Notifications
You must be signed in to change notification settings - Fork 63
[DRAFT] Add support for Silo groups #1358
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
Changes from all commits
121b56d
b963c5d
4a51058
5c85f1b
9d2b3ff
8f8729c
d300cff
2456ed1
34dffd8
2544362
b11a146
5eba13a
29950ba
04b0af5
d82c9f6
0067fb0
0714fa3
1d6ef52
0aa7669
9f8a3ec
e1ef703
566878d
99b752b
c031eca
bb9f567
6e91105
96fc1f3
615b56e
34f49bc
b841c85
54e246e
f3cccc3
35962ce
7837edc
a2507a6
9ee416f
6e79986
df37612
643aadb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -274,13 +274,50 @@ CREATE UNIQUE INDEX ON omicron.public.silo_user ( | |
| ) WHERE | ||
| time_deleted IS NULL; | ||
|
|
||
| CREATE TYPE omicron.public.provider_type AS ENUM ( | ||
| 'saml' | ||
| /* | ||
| * Silo groups | ||
| */ | ||
|
|
||
| CREATE TABLE omicron.public.silo_group ( | ||
| id UUID PRIMARY KEY, | ||
| time_created TIMESTAMPTZ NOT NULL, | ||
| time_modified TIMESTAMPTZ NOT NULL, | ||
| time_deleted TIMESTAMPTZ, | ||
|
|
||
| silo_id UUID NOT NULL, | ||
| external_id TEXT NOT NULL | ||
| ); | ||
|
|
||
| CREATE UNIQUE INDEX ON omicron.public.silo_group ( | ||
| silo_id, | ||
| external_id | ||
| ) WHERE | ||
| time_deleted IS NULL; | ||
|
|
||
| /* | ||
| * Silo group membership | ||
| */ | ||
|
|
||
| CREATE TABLE omicron.public.silo_group_membership ( | ||
| silo_group_id UUID NOT NULL, | ||
| silo_user_id UUID NOT NULL, | ||
|
|
||
| PRIMARY KEY (silo_group_id, silo_user_id) | ||
| ); | ||
|
|
||
| CREATE INDEX ON omicron.public.silo_group_membership ( | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you need |
||
| silo_user_id, | ||
| silo_group_id | ||
| ); | ||
|
|
||
| /* | ||
| * Silo identity provider list | ||
| */ | ||
|
|
||
| CREATE TYPE omicron.public.provider_type AS ENUM ( | ||
| 'saml' | ||
| ); | ||
|
|
||
| CREATE TABLE omicron.public.identity_provider ( | ||
| /* Identity metadata */ | ||
| id UUID PRIMARY KEY, | ||
|
|
@@ -329,7 +366,9 @@ CREATE TABLE omicron.public.saml_identity_provider ( | |
| technical_contact_email TEXT NOT NULL, | ||
|
|
||
| public_cert TEXT, | ||
| private_key TEXT | ||
| private_key TEXT, | ||
|
|
||
| group_attribute_name TEXT | ||
| ); | ||
|
|
||
| CREATE INDEX ON omicron.public.saml_identity_provider ( | ||
|
|
@@ -1422,7 +1461,8 @@ CREATE TABLE omicron.public.role_builtin ( | |
|
|
||
| CREATE TYPE omicron.public.identity_type AS ENUM ( | ||
| 'user_builtin', | ||
| 'silo_user' | ||
| 'silo_user', | ||
| 'silo_group' | ||
| ); | ||
|
|
||
| CREATE TABLE omicron.public.role_assignment ( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| // This Source Code Form is subject to the terms of the Mozilla Public | ||
| // License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| // file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
|
||
| use crate::schema::{silo_group, silo_group_membership}; | ||
| use db_macros::Asset; | ||
| use uuid::Uuid; | ||
|
|
||
| /// Describes a silo group within the database. | ||
| #[derive(Asset, Queryable, Insertable, Debug, Selectable)] | ||
| #[diesel(table_name = silo_group)] | ||
| pub struct SiloGroup { | ||
| #[diesel(embed)] | ||
| identity: SiloGroupIdentity, | ||
|
|
||
| pub silo_id: Uuid, | ||
|
|
||
| /// The identity provider's name for this group. | ||
| pub external_id: String, | ||
| } | ||
|
|
||
| impl SiloGroup { | ||
| pub fn new(id: Uuid, silo_id: Uuid, external_id: String) -> Self { | ||
| Self { identity: SiloGroupIdentity::new(id), silo_id, external_id } | ||
| } | ||
| } | ||
|
|
||
| /// Describe which silo users belong to which silo groups | ||
| #[derive(Queryable, Insertable, Debug, Selectable)] | ||
| #[diesel(table_name = silo_group_membership)] | ||
| pub struct SiloGroupMembership { | ||
| pub silo_group_id: Uuid, | ||
| pub silo_user_id: Uuid, | ||
| } | ||
|
|
||
| impl SiloGroupMembership { | ||
| pub fn new(silo_group_id: Uuid, silo_user_id: Uuid) -> Self { | ||
| Self { silo_group_id, silo_user_id } | ||
| } | ||
| } |
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 seems to me that there's no great time to clean up these groups when they're no longer used. We could clean up a group if there are no role assignments referencing it and no users in it and it's not the admin group. But this might be undesirable if it does still exist in the IdP and someone will want to use it again.
So here's a thought: how about we store in this row a
time_unreferencedcolumn that we update whenever we remove a role assignment referencing it or remove a member from it. That's pretty little work now, but it will allow us to determine later how much of a problem it is to have unreferenced groups. And it gives us a lot of options for cleaning them up. We could clean up groups that haven't been used for a long time, or we could provide the operator a way to do that, etc.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 don't think it'd be a good user experience for the groups to automatically disappear, and even if an operator was to explicitly delete groups that could still cause a lot of confusion if that was done without the knowledge or approval of the appropriate silo user (an SRE or Infra team member or something like that). I would expect groups to remain if I allocated them or if they were JIT allocated during login, and if it were a problem I would write a tool that would remove groups that aren't being used.