Remove the assignment of users and groups to secret roles #3957

Closed
opened 2025-12-29 18:32:16 +01:00 by adam · 2 comments
Owner

Originally created by @jeremystretch on GitHub (Aug 7, 2020).

Originally assigned to: @jeremystretch on GitHub.

Proposed Changes

The SecretRole model has two ManyToManyFields to facilitate the assignment of users and groups to secret roles. This issue proposes removing both of these fields and doing away with this logic entirely.

Justification

With the implementation of object-based permissions (#554), this direct assignment of users and groups to secret roles is no longer necessary. The new permissions architecture provides a standardized and more flexible approach to controlling secrets access.

We would, however, need to take special care when replicating permissions in the database migration: Blindly copying the legacy permissions while dropping SecretRole enforcement would result in any users with the secrets.view_secret permission to view all secrets without respect to their assigned roles. It may be possible to replicate the secret role assignments using constraints automatically. And if not, we should at least exclude secrets permissions from automatic replication, although that would result in the destruction of user data (the secret role assignments).

Originally created by @jeremystretch on GitHub (Aug 7, 2020). Originally assigned to: @jeremystretch on GitHub. ### Proposed Changes The SecretRole model has two ManyToManyFields to facilitate the assignment of users and groups to secret roles. This issue proposes removing both of these fields and doing away with this logic entirely. ### Justification With the implementation of object-based permissions (#554), this direct assignment of users and groups to secret roles is no longer necessary. The new permissions architecture provides a standardized and more flexible approach to controlling secrets access. We would, however, need to take special care when replicating permissions in the database migration: Blindly copying the legacy permissions while dropping SecretRole enforcement would result in any users with the `secrets.view_secret` permission to view _all_ secrets without respect to their assigned roles. It may be possible to replicate the secret role assignments using constraints automatically. And if not, we should at least exclude secrets permissions from automatic replication, although that would result in the destruction of user data (the secret role assignments).
adam added the status: acceptedtype: deprecationbeta labels 2025-12-29 18:32:16 +01:00
adam closed this issue 2025-12-29 18:32:16 +01:00
Author
Owner

@jeremystretch commented on GitHub (Aug 7, 2020):

Opened draft PR #4972 for testing

@jeremystretch commented on GitHub (Aug 7, 2020): Opened draft PR #4972 for testing
Author
Owner

@jeremystretch commented on GitHub (Aug 10, 2020):

It may be possible to replicate the secret role assignments using constraints automatically.

I ended up extending the 0009_replicate_permissions to handle the dcim.view_secret permission as a special condition, attaching constraints to mimic the assignment of users and groups to secret roles. Permissions are created only if the user/group both a) has the view_secret permission and b) is assigned to one or more secret roles. Constraints are applied using the secret role's name.

@jeremystretch commented on GitHub (Aug 10, 2020): > It may be possible to replicate the secret role assignments using constraints automatically. I ended up extending the `0009_replicate_permissions` to handle the `dcim.view_secret` permission as a special condition, attaching constraints to mimic the assignment of users and groups to secret roles. Permissions are created only if the user/group both a) has the `view_secret` permission _and_ b) is assigned to one or more secret roles. Constraints are applied using the secret role's name.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#3957