1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Remove activate_userkey permission

This commit is contained in:
Jeremy Stretch
2020-06-02 09:47:31 -04:00
parent 110bad7041
commit c6e85970d4
5 changed files with 9 additions and 6 deletions

View File

@ -11,3 +11,7 @@ NetBox v2.9 replaces Django's built-in permissions framework with one that suppo
### Configuration Changes ### Configuration Changes
* `REMOTE_AUTH_DEFAULT_PERMISSIONS` now takes a dictionary rather than a list. This is a mapping of permission names to a dictionary of constraining attributes, or `None`. For example, `['dcim.add_site', 'dcim.change_site']` would become `{'dcim.add_site': None, 'dcim.change_site': None}`. * `REMOTE_AUTH_DEFAULT_PERMISSIONS` now takes a dictionary rather than a list. This is a mapping of permission names to a dictionary of constraining attributes, or `None`. For example, `['dcim.add_site', 'dcim.change_site']` would become `{'dcim.add_site': None, 'dcim.change_site': None}`.
### Other Changes
* The `secrets.activate_userkey` permission no longer exists. Instead, `secrets.change_userkey` is checked to determine whether a user has the ability to activate a UserKey.

View File

@ -23,7 +23,7 @@ class UserKeyAdmin(admin.ModelAdmin):
actions = super().get_actions(request) actions = super().get_actions(request)
if 'delete_selected' in actions: if 'delete_selected' in actions:
del actions['delete_selected'] del actions['delete_selected']
if not request.user.has_perm('secrets.activate_userkey'): if not request.user.has_perm('secrets.change_userkey'):
del actions['activate_selected'] del actions['activate_selected']
return actions return actions

View File

@ -56,7 +56,6 @@ class Migration(migrations.Migration):
], ],
options={ options={
'ordering': ['user__username'], 'ordering': ['user__username'],
'permissions': (('activate_userkey', 'Can activate user keys for decryption'),),
}, },
), ),
migrations.AddField( migrations.AddField(

View File

@ -64,9 +64,6 @@ class UserKey(models.Model):
class Meta: class Meta:
ordering = ['user__username'] ordering = ['user__username']
permissions = (
('activate_userkey', "Can activate user keys for decryption"),
)
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)

View File

@ -14,9 +14,12 @@ def replicate_permissions(apps, schema_editor):
# TODO: Optimize this iteration so that ObjectPermissions with identical sets of users and groups # TODO: Optimize this iteration so that ObjectPermissions with identical sets of users and groups
# are combined into a single ObjectPermission instance. # are combined into a single ObjectPermission instance.
for perm in Permission.objects.all(): for perm in Permission.objects.all():
# Account for non-standard permission names; e.g. napalm_read
if perm.codename.split('_')[0] in ACTIONS: if perm.codename.split('_')[0] in ACTIONS:
# Account for non-standard legacy permission names; e.g. napalm_read
action = perm.codename.split('_')[0] action = perm.codename.split('_')[0]
elif perm.codename == 'activate_userkey':
# Rename activate_userkey permission
action = 'change'
else: else:
action = perm.codename action = perm.codename