diff --git a/apps/assets/const/protocol.py b/apps/assets/const/protocol.py index d1ce663b8..7875e5ef4 100644 --- a/apps/assets/const/protocol.py +++ b/apps/assets/const/protocol.py @@ -1,4 +1,5 @@ from django.db import models + from common.db.models import ChoicesMixin __all__ = ['Protocol'] @@ -102,9 +103,9 @@ class Protocol(ChoicesMixin, models.TextChoices): 'port': 80, 'secret_types': ['password'], 'setting': { - 'username_selector': 'input[type=text]', - 'password_selector': 'input[type=password]', - 'submit_selector': 'button[type=submit]', + 'username_selector': 'name=username', + 'password_selector': 'name=password', + 'submit_selector': 'id=longin_button', } }, } @@ -112,7 +113,7 @@ class Protocol(ChoicesMixin, models.TextChoices): @classmethod def settings(cls): return { - **cls.device_protocols(), - **cls.database_protocols(), - **cls.cloud_protocols() + **cls.device_protocols(), + **cls.database_protocols(), + **cls.cloud_protocols() } diff --git a/apps/assets/serializers/asset/web.py b/apps/assets/serializers/asset/web.py index 333795473..aa35e28e0 100644 --- a/apps/assets/serializers/asset/web.py +++ b/apps/assets/serializers/asset/web.py @@ -1,4 +1,3 @@ - from assets.models import Web from .common import AssetSerializer @@ -19,12 +18,12 @@ class WebSerializer(AssetSerializer): 'label': 'URL' }, 'username_selector': { - 'default': 'input[type=text]' + 'default': 'name=username' }, 'password_selector': { - 'default': 'input[type=password]' + 'default': 'name=password' }, 'submit_selector': { - 'default': 'button[type=submit]', + 'default': 'id=longin_button', }, } diff --git a/apps/perms/utils/user_perm_tree.py b/apps/perms/utils/user_perm_tree.py index d45b6a325..794ea3efc 100644 --- a/apps/perms/utils/user_perm_tree.py +++ b/apps/perms/utils/user_perm_tree.py @@ -3,24 +3,23 @@ from collections import defaultdict from django.core.cache import cache -from users.models import User +from common.decorator import on_transaction_commit +from common.utils import get_logger +from common.utils.common import lazyproperty, timeit from orgs.models import Organization from orgs.utils import ( tmp_to_org, tmp_to_root_org ) -from common.decorator import on_transaction_commit -from common.utils import get_logger -from common.utils.common import lazyproperty, timeit - from perms.locks import UserGrantedTreeRebuildLock from perms.models import ( AssetPermission, UserAssetGrantedTreeNodeRelation ) +from perms.utils.user_permission import UserGrantedTreeBuildUtils +from users.models import User from .permission import AssetPermissionUtil - logger = get_logger(__name__) __all__ = ['UserPermTreeRefreshUtil', 'UserPermTreeExpireUtil'] @@ -69,7 +68,7 @@ class UserPermTreeRefreshUtil(_UserPermTreeCacheMixin): end = time.time() logger.info( 'Refresh user [{user}] org [{org}] perm tree, user {use_time:.2f}s' - ''.format(user=self.user, org=org, use_time=end-start) + ''.format(user=self.user, org=org, use_time=end - start) ) def clean_user_perm_tree_nodes_for_legacy_org(self): @@ -142,4 +141,3 @@ class UserPermTreeExpireUtil(_UserPermTreeCacheMixin): p.delete(k) p.execute() logger.info('Expire all user perm tree') -