mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-06-04 12:49:37 +00:00
perf: update tk create
This commit is contained in:
parent
d3176b68a8
commit
be72344c63
@ -72,10 +72,6 @@ class ConnectionToken(JMSOrgBaseModel):
|
|||||||
]
|
]
|
||||||
verbose_name = _('Connection token')
|
verbose_name = _('Connection token')
|
||||||
|
|
||||||
def save(self, *args, **kwargs):
|
|
||||||
self.type = self._type
|
|
||||||
return super().save(*args, **kwargs)
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_typed_connection_token(cls, token_id):
|
def get_typed_connection_token(cls, token_id):
|
||||||
token = get_object_or_404(cls, id=token_id)
|
token = get_object_or_404(cls, id=token_id)
|
||||||
@ -99,6 +95,7 @@ class ConnectionToken(JMSOrgBaseModel):
|
|||||||
return int(seconds)
|
return int(seconds)
|
||||||
|
|
||||||
def save(self, *args, **kwargs):
|
def save(self, *args, **kwargs):
|
||||||
|
self.type = self._type
|
||||||
self.asset_display = pretty_string(self.asset, max_length=128)
|
self.asset_display = pretty_string(self.asset, max_length=128)
|
||||||
self.user_display = pretty_string(self.user, max_length=128)
|
self.user_display = pretty_string(self.user, max_length=128)
|
||||||
return super().save(*args, **kwargs)
|
return super().save(*args, **kwargs)
|
||||||
@ -341,9 +338,13 @@ class AdminConnectionToken(ConnectionToken):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_user_permed_account(cls, user, asset, account_name, protocol):
|
def get_user_permed_account(cls, user, asset, account_name, protocol):
|
||||||
account = asset.accounts.filter(name=account_name).first()
|
"""
|
||||||
if not account:
|
管理员 token 可以访问所有资产的账号
|
||||||
return None
|
"""
|
||||||
|
with tmp_to_org(asset.org_id):
|
||||||
|
account = asset.accounts.filter(name=account_name).first()
|
||||||
|
if not account:
|
||||||
|
return None
|
||||||
account.actions = ActionChoices.all()
|
account.actions = ActionChoices.all()
|
||||||
account.date_expired = timezone.now() + timezone.timedelta(days=5)
|
account.date_expired = timezone.now() + timezone.timedelta(days=5)
|
||||||
return account
|
return account
|
||||||
|
Loading…
Reference in New Issue
Block a user