perf: account perm (#9595)

Co-authored-by: feng <1304903146@qq.com>
pull/9596/head
fit2bot 2023-02-16 19:39:10 +08:00 committed by GitHub
parent fc2d7aafce
commit f7500b8aff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 4 deletions

View File

@ -30,7 +30,7 @@ class AccountViewSet(OrgBulkModelViewSet):
} }
rbac_perms = { rbac_perms = {
'verify_account': 'accounts.test_account', 'verify_account': 'accounts.test_account',
'partial_update': ['accounts.change_accountsecret', 'accounts.change_account'], 'partial_update': ['accounts.change_account'],
'su_from_accounts': 'accounts.view_account', 'su_from_accounts': 'accounts.view_account',
} }
@ -66,7 +66,7 @@ class AccountSecretsViewSet(RecordViewLogMixin, AccountViewSet):
'default': serializers.AccountSecretSerializer, 'default': serializers.AccountSecretSerializer,
} }
http_method_names = ['get', 'options'] http_method_names = ['get', 'options']
permission_classes = [RBACPermission, UserConfirmation.require(ConfirmType.MFA)] # permission_classes = [RBACPermission, UserConfirmation.require(ConfirmType.MFA)]
rbac_perms = { rbac_perms = {
'list': 'accounts.view_accountsecret', 'list': 'accounts.view_accountsecret',
'retrieve': 'accounts.view_accountsecret', 'retrieve': 'accounts.view_accountsecret',

View File

@ -0,0 +1,17 @@
# Generated by Django 3.2.16 on 2023-02-16 11:07
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('accounts', '0006_gatheredaccount'),
]
operations = [
migrations.AlterModelOptions(
name='account',
options={'permissions': [('view_accountsecret', 'Can view asset account secret'), ('view_historyaccount', 'Can view asset history account'), ('view_historyaccountsecret', 'Can view asset history account secret')], 'verbose_name': 'Account'},
),
]

View File

@ -62,7 +62,6 @@ class Account(AbsConnectivity, BaseAccount):
] ]
permissions = [ permissions = [
('view_accountsecret', _('Can view asset account secret')), ('view_accountsecret', _('Can view asset account secret')),
('change_accountsecret', _('Can change asset account secret')),
('view_historyaccount', _('Can view asset history account')), ('view_historyaccount', _('Can view asset history account')),
('view_historyaccountsecret', _('Can view asset history account secret')), ('view_historyaccountsecret', _('Can view asset history account secret')),
] ]

View File

@ -27,7 +27,7 @@ def migrate_remove_redundant_permission(apps, *args):
perm_model = apps.get_model('auth', 'Permission') perm_model = apps.get_model('auth', 'Permission')
perm_model.objects.filter(codename__in=[ perm_model.objects.filter(codename__in=[
'view_permusergroupasset', 'view_permuserasset', 'push_assetsystemuser' 'view_permusergroupasset', 'view_permuserasset', 'push_assetsystemuser', 'change_accountsecret'
]).delete() ]).delete()