mirror of https://github.com/jumpserver/jumpserver
fix: Authbook 修改秘钥不生效
parent
764d70ea4f
commit
2f43aeee5d
|
@ -6,6 +6,7 @@ from orgs.mixins.serializers import BulkOrgResourceModelSerializer
|
||||||
|
|
||||||
from .base import AuthSerializerMixin
|
from .base import AuthSerializerMixin
|
||||||
from .utils import validate_password_contains_left_double_curly_bracket
|
from .utils import validate_password_contains_left_double_curly_bracket
|
||||||
|
from common.utils.encode import ssh_pubkey_gen
|
||||||
|
|
||||||
|
|
||||||
class AccountSerializer(AuthSerializerMixin, BulkOrgResourceModelSerializer):
|
class AccountSerializer(AuthSerializerMixin, BulkOrgResourceModelSerializer):
|
||||||
|
@ -40,6 +41,21 @@ class AccountSerializer(AuthSerializerMixin, BulkOrgResourceModelSerializer):
|
||||||
}
|
}
|
||||||
ref_name = 'AssetAccountSerializer'
|
ref_name = 'AssetAccountSerializer'
|
||||||
|
|
||||||
|
def _validate_gen_key(self, attrs):
|
||||||
|
private_key = attrs.get('private_key')
|
||||||
|
if not private_key:
|
||||||
|
return attrs
|
||||||
|
|
||||||
|
password = attrs.get('passphrase')
|
||||||
|
username = attrs.get('username')
|
||||||
|
public_key = ssh_pubkey_gen(private_key, password=password, username=username)
|
||||||
|
attrs['public_key'] = public_key
|
||||||
|
return attrs
|
||||||
|
|
||||||
|
def validate(self, attrs):
|
||||||
|
attrs = self._validate_gen_key(attrs)
|
||||||
|
return attrs
|
||||||
|
|
||||||
def get_protocols(self, v):
|
def get_protocols(self, v):
|
||||||
return v.protocols.replace(' ', ', ')
|
return v.protocols.replace(' ', ', ')
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue