-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Description
NetBox version
v3.5.4
Feature type
New functionality
Proposed functionality
Expose a new configuration parameter DEFAULT_PERMISSIONS defining a two-tuple of permission names and constraints. For example:
DEFAULT_PERMISSIONS = (
("dcim.delete_site", {"status": "retired"}),
)The defined permissions and constraints will apply to all authenticated users, obviating the need for an administrator to explicitly assign them. Administrators can define their own DEFAULT_PERMISSIONS to override or extend the default values.
At some point in the future, this might replace the need for the EXEMPT_VIEW_PERMISSIONS configuration parameter, however its deprecation is not implied by this proposal.
Use case
There are two specific use cases driving this proposal.
API Tokens
NetBox currently allows every user to manage their own API tokens via the web user interface, regardless of permissions assigned. There have been requests to restrict this ability, however to date no specific solution has been proposed.
This FR would unlock the ability to restrict token creation by setting the following default permissions:
DEFAULT_PERMISSIONS = (
("users.add_token", {"user": "$user"}),
("users.change_token", {"user": "$user"}),
("users.delete_token", {"user": "$user"}),
)These default permissions would grant the ability to each user to create, edit, and delete their own tokens, obviating the need for unique logic effecting this in the UI views. Administrators who wish to restrict this ability can override the DEFAULT_PERMISSIONS configuration parameter to remove these permissions.
Bookmarks
#8248 proposes the ability for users to bookmark arbitrary objects in NetBox for their convenience (similar to how a web browser allows it user to bookmark web pages). As bookmarks are only ever relevant to the user who owns them, it seems reasonable to grant all users permission to bookmark objects by default. Similar to API tokens, this could be done by declaring default permissions to this effect, which can be overridden by a local administrator if needed.
Database changes
None
External dependencies
None