mirror of
https://github.com/netbox-community/netbox.git
synced 2025-12-18 11:22:25 -06:00
* Introduce the DEFAULT_PERMISSIONS config parameter * Establish default permissions for user token management
This commit is contained in:
@@ -68,8 +68,13 @@ When defining a permission constraint, administrators may use the special token
|
||||
|
||||
The `$user` token can be used only as a constraint value, or as an item within a list of values. It cannot be modified or extended to reference specific user attributes.
|
||||
|
||||
### Default Permissions
|
||||
|
||||
#### Example Constraint Definitions
|
||||
!!! info "This feature was introduced in NetBox v3.6."
|
||||
|
||||
While permissions are typically assigned to specific groups and/or users, it is also possible to define a set of default permissions that are applied to _all_ authenticated users. This is done using the [`DEFAULT_PERMISSIONS`](../configuration/security.md#default_permissions) configuration parameter. Note that statically configuring permissions for specific users or groups is **not** supported.
|
||||
|
||||
### Example Constraint Definitions
|
||||
|
||||
| Constraints | Description |
|
||||
| ----------- | ----------- |
|
||||
|
||||
@@ -90,6 +90,38 @@ CSRF_TRUSTED_ORIGINS = (
|
||||
|
||||
---
|
||||
|
||||
## DEFAULT_PERMISSIONS
|
||||
|
||||
!!! info "This parameter was introduced in NetBox v3.6."
|
||||
|
||||
Default:
|
||||
|
||||
```python
|
||||
{
|
||||
'users.view_token': ({'user': '$user'},),
|
||||
'users.add_token': ({'user': '$user'},),
|
||||
'users.change_token': ({'user': '$user'},),
|
||||
'users.delete_token': ({'user': '$user'},),
|
||||
}
|
||||
```
|
||||
|
||||
This parameter defines object permissions that are applied automatically to _any_ authenticated user, regardless of what permissions have been defined in the database. By default, this parameter is defined to allow all users to manage their own API tokens, however it can be overriden for any purpose.
|
||||
|
||||
For example, to allow all users to create a device role beginning with the word "temp," you could configure the following:
|
||||
|
||||
```python
|
||||
DEFAULT_PERMISSIONS = {
|
||||
'dcim.add_devicerole': (
|
||||
{'name__startswith': 'temp'},
|
||||
)
|
||||
}
|
||||
```
|
||||
|
||||
!!! warning
|
||||
Setting a custom value for this parameter will overwrite the default permission mapping shown above. If you want to retain the default mapping, be sure to reproduce it in your custom configuration.
|
||||
|
||||
---
|
||||
|
||||
## EXEMPT_VIEW_PERMISSIONS
|
||||
|
||||
Default: Empty list
|
||||
|
||||
Reference in New Issue
Block a user