Sam
02/25/2022, 12:33 AMuser
02/25/2022, 3:04 AMpermission list_widgets = ...
user
02/25/2022, 3:05 AM/v1/myorganization/widgets/
williamdclt
02/25/2022, 2:52 PMdefinition user {}
/* feature flags can be enabled per organisation */
definition flag {}
/* we have multiple organisations in our system */
definition organization {
/* each organisation has multiple users */
relation member: user
/* each organisation has multiple admins */
relation admin: user
/* this represents whether this org has the new_admin_dashboard
* feature flag enabled */
relation flag_new_admin_dashboard: flag
/* to access the new admin dashboard, the user needs to be an admin and
* the org needs to have the new_admin_dashboard feature flag enabled */
permission view_new_admin_dashboard = admin & flag_new_admin_dashboard // doesn't work :(
}
I just can't seem to figure out how to implement this view_new_admin_dashboard
permission! I've been reading the docs for hours but I'm probably still missing the correct mental model, could you help me out?Joey
02/25/2022, 4:03 PMflag_new_admin_dashboard
needs to end in a set of users for the &
to workJoey
02/25/2022, 4:03 PMflag
link back to its organizationJoey
02/25/2022, 4:04 PMdefinition flag {
relation organization: organization
permission org_admin = organization->admin
}
Joey
02/25/2022, 4:04 PMview_new_admin_dashboard = admin & flag_new_admin_dashboard->org_admin
Joey
02/25/2022, 4:05 PMwilliamdclt
02/25/2022, 4:25 PMflag:new_admin_dashboard#flag_new_admin_dashboard@organization:my_org
- organization:my_org#organization@flag:new_admin_dashboard
That's redundant, which makes me sad 😢
For reference, our current system which works very very similarly to SpiceDB (SPARQL-based, also Zanzibar-inspired) is based on checking that a set of relationships exist. So our policy would look something like (this is a made-up policy format):
permission view_new_admin_dashboard: flag:new_admin_dashboard#flag_enabled@organization:{subject} AND user:{object}#admin@organization:{subject}
This does not have the problem of storing duplicated relations, nor do I need the awkward flag_new_admin_dashboard
relation: I can hardcode a specific flag directly in my policy and have a generic flag_enabled
relation.
I'm super keen to use SpiceDB as it does everything we had to implement ourselves, and very likely it does better! But being able to easily handle feature-flags (and similar things like user settings) is super important for us: is there any other approach I could explore?Joey
02/25/2022, 4:27 PMdefinition organization {
relation admin: user
relation feature_flag_new_admin_dashboard: organization#admin
permission view_new_admin_dashboard = feature_flag_new_admin_dashboard
}
Joey
02/25/2022, 4:27 PMorganization:foo#feature_flag_new_admin_dashboard@organization:foo#admin
Joey
02/25/2022, 4:27 PMJoey
02/25/2022, 4:33 PMwilliamdclt
02/25/2022, 4:37 PMorganization#admin
means here, but I'll figure it outJoey
02/25/2022, 4:45 PMwilliamdclt
02/25/2022, 4:55 PMuser:123 is admin of org:foo
and flag:new_admin_dashboard is enabled in org:foo
and walk through these relations to decide permissions.
Here I'd have to write the admins of org:foo have feature_flag_new_admin_dashboard in org:foo
which doesn't make a lot of sense (feature_flag_new_admin_dashboard
shouldn't really be a relationship) and encodes part of the permission logic within the relationship (the user needs to be an admin of the organisation), which makes it harder to evolve in the future.williamdclt
02/25/2022, 4:58 PMJoey
02/25/2022, 5:07 PMJoey
02/25/2022, 5:08 PMJoey
02/25/2022, 5:08 PMJoey
02/25/2022, 5:08 PMrelation new_admin_dashboard_viewer
user
02/25/2022, 5:10 PMJoey
02/25/2022, 5:12 PMJoey
02/25/2022, 5:12 PMJoey
02/25/2022, 5:16 PMdefinition organization {
relation admin: user
relation feature_new_admin_dashboard_enabled_on: organization
permission view_new_admin_dashboard = feature_new_admin_dashboard_enabled_on->admin & admin
}
Joey
02/25/2022, 5:19 PMwilliamdclt
02/25/2022, 5:22 PMwilliamdclt
02/25/2022, 5:23 PMJoey
02/25/2022, 5:30 PM