mirror of https://github.com/jumpserver/jumpserver
[Update] 更新系统用户认证信息private_key转换
parent
f88cb3da20
commit
005272cdc0
|
@ -1,5 +1,6 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
#
|
#
|
||||||
|
import io
|
||||||
import os
|
import os
|
||||||
import uuid
|
import uuid
|
||||||
from hashlib import md5
|
from hashlib import md5
|
||||||
|
@ -76,6 +77,14 @@ class AssetUser(OrgModelMixin):
|
||||||
i = '-'.join(str(self.id).split('-')[:3])
|
i = '-'.join(str(self.id).split('-')[:3])
|
||||||
return i
|
return i
|
||||||
|
|
||||||
|
def get_private_key(self):
|
||||||
|
if not self.private_key_obj:
|
||||||
|
return None
|
||||||
|
string_io = io.StringIO()
|
||||||
|
self.private_key_obj.write_private_key(string_io)
|
||||||
|
private_key = string_io.getvalue()
|
||||||
|
return private_key
|
||||||
|
|
||||||
def get_related_assets(self):
|
def get_related_assets(self):
|
||||||
assets = self.assets.all()
|
assets = self.assets.all()
|
||||||
return assets
|
return assets
|
||||||
|
|
|
@ -123,6 +123,7 @@ class SystemUserAuthSerializer(AuthSerializer):
|
||||||
"""
|
"""
|
||||||
系统用户认证信息
|
系统用户认证信息
|
||||||
"""
|
"""
|
||||||
|
private_key = serializers.SerializerMethodField()
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = SystemUser
|
model = SystemUser
|
||||||
|
@ -131,6 +132,10 @@ class SystemUserAuthSerializer(AuthSerializer):
|
||||||
"login_mode", "password", "private_key",
|
"login_mode", "password", "private_key",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_private_key(obj):
|
||||||
|
return obj.get_private_key()
|
||||||
|
|
||||||
|
|
||||||
class SystemUserSimpleSerializer(serializers.ModelSerializer):
|
class SystemUserSimpleSerializer(serializers.ModelSerializer):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue