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
9ffb079c
Commit
9ffb079c
authored
Mar 09, 2018
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Update] 增加修改system user auth 的api
parent
9162f4a2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
13 deletions
+34
-13
system_user.py
apps/assets/api/system_user.py
+10
-11
system_user.py
apps/assets/serializers/system_user.py
+15
-0
settings.py
apps/jumpserver/settings.py
+9
-2
No files found.
apps/assets/api/system_user.py
View file @
9ffb079c
...
...
@@ -40,23 +40,22 @@ class SystemUserViewSet(BulkModelViewSet):
permission_classes
=
(
IsSuperUserOrAppUser
,)
class
SystemUserAuthInfoApi
(
generics
.
RetrieveAPIView
):
class
SystemUserAuthInfoApi
(
generics
.
Retrieve
Update
APIView
):
"""
Get system user auth info
"""
queryset
=
SystemUser
.
objects
.
all
()
permission_classes
=
(
IsSuperUserOrAppUser
,)
serializer_class
=
serializers
.
SystemUserAuthSerializer
def
retrieve
(
self
,
request
,
*
args
,
**
kwargs
):
system_user
=
self
.
get_object
()
data
=
{
'id'
:
system_user
.
id
,
'name'
:
system_user
.
name
,
'username'
:
system_user
.
username
,
'password'
:
system_user
.
password
,
'private_key'
:
system_user
.
private_key
,
}
return
Response
(
data
)
def
update
(
self
,
request
,
*
args
,
**
kwargs
):
password
=
request
.
data
.
pop
(
"password"
,
None
)
private_key
=
request
.
data
.
pop
(
"private_key"
,
None
)
instance
=
self
.
get_object
()
if
password
or
private_key
:
instance
.
set_auth
(
password
=
password
,
private_key
=
private_key
)
return
super
()
.
update
(
request
,
*
args
,
**
kwargs
)
class
SystemUserPushApi
(
generics
.
RetrieveAPIView
):
...
...
apps/assets/serializers/system_user.py
View file @
9ffb079c
...
...
@@ -36,6 +36,21 @@ class SystemUserSerializer(serializers.ModelSerializer):
return
len
(
obj
.
assets
)
class
SystemUserAuthSerializer
(
serializers
.
ModelSerializer
):
"""
系统用户认证信息
"""
password
=
serializers
.
CharField
(
max_length
=
1024
)
private_key
=
serializers
.
CharField
(
max_length
=
4096
)
class
Meta
:
model
=
SystemUser
fields
=
[
"id"
,
"name"
,
"username"
,
"protocol"
,
"password"
,
"private_key"
,
]
class
AssetSystemUserSerializer
(
serializers
.
ModelSerializer
):
"""
查看授权的资产系统用户的数据结构,这个和AssetSerializer不同,字段少
...
...
apps/jumpserver/settings.py
View file @
9ffb079c
...
...
@@ -27,7 +27,14 @@ sys.path.append(PROJECT_DIR)
try
:
from
config
import
config
as
CONFIG
except
ImportError
:
CONFIG
=
type
(
'_'
,
(),
{
'__getattr__'
:
lambda
arg1
,
arg2
:
None
})()
msg
=
"""
Error: No config file found.
You can run `cp config_example.py config.py`, and edit it.
"""
raise
ImportError
(
msg
)
# CONFIG = type('_', (), {'__getattr__': lambda arg1, arg2: None})()
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/
...
...
@@ -177,7 +184,7 @@ LOGGING = {
'level'
:
'DEBUG'
,
'class'
:
'logging.FileHandler'
,
'formatter'
:
'main'
,
'filename'
:
os
.
path
.
join
(
CONFIG
.
LOG_DIR
,
'jumpserver.log'
)
'filename'
:
os
.
path
.
join
(
PROJECT_DIR
,
'logs'
,
'jumpserver.log'
)
},
'ansible_logs'
:
{
'level'
:
'DEBUG'
,
...
...
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