Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
J
jumpserver
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ops
jumpserver
Commits
005272cd
Commit
005272cd
authored
Jan 07, 2020
by
Bai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Update] 更新系统用户认证信息private_key转换
parent
f88cb3da
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
0 deletions
+14
-0
base.py
apps/assets/models/base.py
+9
-0
system_user.py
apps/assets/serializers/system_user.py
+5
-0
No files found.
apps/assets/models/base.py
View file @
005272cd
# -*- coding: utf-8 -*-
#
import
io
import
os
import
uuid
from
hashlib
import
md5
...
...
@@ -76,6 +77,14 @@ class AssetUser(OrgModelMixin):
i
=
'-'
.
join
(
str
(
self
.
id
)
.
split
(
'-'
)[:
3
])
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
):
assets
=
self
.
assets
.
all
()
return
assets
...
...
apps/assets/serializers/system_user.py
View file @
005272cd
...
...
@@ -123,6 +123,7 @@ class SystemUserAuthSerializer(AuthSerializer):
"""
系统用户认证信息
"""
private_key
=
serializers
.
SerializerMethodField
()
class
Meta
:
model
=
SystemUser
...
...
@@ -131,6 +132,10 @@ class SystemUserAuthSerializer(AuthSerializer):
"login_mode"
,
"password"
,
"private_key"
,
]
@staticmethod
def
get_private_key
(
obj
):
return
obj
.
get_private_key
()
class
SystemUserSimpleSerializer
(
serializers
.
ModelSerializer
):
"""
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment