Snapshot, diff, and apply for roles and permissions #21124
becdetat
started this conversation in
Feature Requests
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Summary
Similar to the excellent schema management endpoints, there should be a way to manage roles and permissions.
This is similar in spirit but not implementation to #13041.
Basic Example
Three new API endpoints, similar in operation to the existing
/schema/*APIs.access-controlmight not be the best name but this is the idea:GET /access-control/snapshot- Retreive a snapshot of the access controls, including roles and permissionsPOST /access-control/diff- Retrieve the diff between the posted snapshot and the current access controlsPOST /access-control/apply- Apply the posted diffThis will allow programmatic management of access control across Directus instances, removing the need for human interaction to build applications across different environments, and make it possible to store access control configuration in source control as a JSON file, alongside the schema JSON.
Motivation
We want to create Directus applications in a repeatable fashion, going from local development to a test environment to production. We can reproduce the schema using the
/schemaAPIs, however there is no comparable way to generate and apply access control, which forms a critical part of the application. Having a set of APIs that allow building a repeatable set of access controls would enable better development practices.Detailed Design
This is a high level feature request so I won't get deep into implementation details.
This feature should be similar in operation to the
/schemaAPIs:Requirements List
Must Have:
/schemaAPIs in terms of functionalityDrawbacks
Access control is complex, going down into custom permissions for example.
Alternatives
There are existing APIs that allow CRUD management of roles and permissions, however implementing repeatable environments using these APIs would be highly onerous compared to a set of APIs similar to the
/schema/*APIs.Adoption Strategy
This isn't a breaking change, it would be an additional set of APIs that allow repeatable deployment of access controls to multiple Directus instances.
Unresolved Questions
Roles are applied to users, and if
/access-controls/applyallows the destruction of roles, existing users with those roles would suddenly not have them. While this is probably desirable behaviour, it may be unexpected.Note that this already applies to content that is affected by schema changes via
/schema/apply.All reactions