mirror of https://github.com/jumpserver/jumpserver
fix: 修改 ConnectionToken Serializer
parent
52e8082470
commit
a70f85e346
|
@ -125,6 +125,8 @@ class CommandFilterACL(OrgModelMixin, BaseACL):
|
|||
|
||||
@classmethod
|
||||
def get_command_groups(cls, user_id=None, user_group_id=None, account=None, asset_id=None, org_id=None):
|
||||
# Todo: Do
|
||||
return CommandGroup.objects.all()
|
||||
|
||||
from assets.models import Account, Asset
|
||||
user_groups = []
|
||||
|
|
|
@ -121,26 +121,31 @@ class ConnectionToken(OrgModelMixin, JMSBaseModel):
|
|||
|
||||
@lazyproperty
|
||||
def account(self):
|
||||
from assets.models import Account
|
||||
if not self.asset:
|
||||
return None
|
||||
|
||||
account = self.asset.accounts.filter(name=self.account_name).first()
|
||||
if self.account_name == '@INPUT' or not account:
|
||||
return {
|
||||
data = {
|
||||
'name': self.account_name,
|
||||
'username': self.input_username,
|
||||
'secret_type': 'password',
|
||||
'secret': self.input_secret,
|
||||
'su_from': None
|
||||
'su_from': None,
|
||||
'org_id': self.asset.org_id
|
||||
}
|
||||
Account(**data)
|
||||
else:
|
||||
return {
|
||||
data = {
|
||||
'name': account.name,
|
||||
'username': account.username,
|
||||
'secret_type': account.secret_type,
|
||||
'secret': account.secret or self.input_secret,
|
||||
'su_from': account.su_from,
|
||||
'org_id': account.org_id
|
||||
}
|
||||
return Account(**data)
|
||||
|
||||
@lazyproperty
|
||||
def domain(self):
|
||||
|
|
|
@ -120,8 +120,8 @@ class ConnectionTokenGatewaySerializer(serializers.ModelSerializer):
|
|||
class Meta:
|
||||
model = Asset
|
||||
fields = [
|
||||
'id', 'address', 'port', 'username',
|
||||
'password', 'private_key'
|
||||
'id', 'address', 'port',
|
||||
# 'username', 'password', 'private_key'
|
||||
]
|
||||
|
||||
|
||||
|
@ -131,8 +131,7 @@ class ConnectionTokenACLCmdGroupSerializer(serializers.ModelSerializer):
|
|||
class Meta:
|
||||
model = CommandGroup
|
||||
fields = [
|
||||
'id', 'type', 'content', 'ignore_case', 'pattern',
|
||||
'action', 'date_created',
|
||||
'id', 'type', 'content', 'ignore_case', 'pattern'
|
||||
]
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue