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
4fc38a91
Commit
4fc38a91
authored
Aug 06, 2019
by
BaiJiangJie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Feature] 应用管理: Database 添加获取数据库认证信息的API
parent
dcd1c119
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
5 deletions
+21
-5
database.py
apps/applications/api/database.py
+10
-3
database.py
apps/applications/serializers/database.py
+6
-1
api_urls.py
apps/applications/urls/api_urls.py
+5
-1
No files found.
apps/applications/api/database.py
View file @
4fc38a91
# coding: utf-8
#
from
rest_framework
import
generics
from
rest_framework.pagination
import
LimitOffsetPagination
from
rest_framework_bulk
import
BulkModelViewSet
from
..hands
import
IsOrgAdmin
from
..hands
import
IsOrgAdmin
,
IsAppUser
from
..models
import
Database
from
..serializers
import
DatabaseSerializer
from
..serializers
import
DatabaseSerializer
,
DatabaseAuthInfoSerializer
__all__
=
[
'DataBaseViewSet'
]
__all__
=
[
'DataBaseViewSet'
,
'DatabaseAuthInfoApi'
]
class
DataBaseViewSet
(
BulkModelViewSet
):
...
...
@@ -18,3 +19,9 @@ class DataBaseViewSet(BulkModelViewSet):
queryset
=
Database
.
objects
.
all
()
serializer_class
=
DatabaseSerializer
pagination_class
=
LimitOffsetPagination
class
DatabaseAuthInfoApi
(
generics
.
RetrieveAPIView
):
queryset
=
Database
.
objects
.
all
()
permission_classes
=
(
IsAppUser
,)
serializer_class
=
DatabaseAuthInfoSerializer
apps/applications/serializers/database.py
View file @
4fc38a91
...
...
@@ -7,7 +7,7 @@ from common.serializers import AdaptedBulkListSerializer
from
orgs.mixins
import
BulkOrgResourceModelSerializer
from
..models
import
Database
__all__
=
[
'DatabaseSerializer'
]
__all__
=
[
'DatabaseSerializer'
,
'DatabaseAuthInfoSerializer'
]
class
DatabaseSerializer
(
BulkOrgResourceModelSerializer
):
...
...
@@ -45,3 +45,8 @@ class DatabaseSerializer(BulkOrgResourceModelSerializer):
self
.
clean_password
(
validated_data
)
return
super
()
.
update
(
instance
,
validated_data
)
class
DatabaseAuthInfoSerializer
(
serializers
.
ModelSerializer
):
class
Meta
:
model
=
Database
fields
=
[
'password'
]
apps/applications/urls/api_urls.py
View file @
4fc38a91
...
...
@@ -16,7 +16,11 @@ router.register(r'databases', api.DataBaseViewSet, 'database')
urlpatterns
=
[
path
(
'remote-apps/<uuid:pk>/connection-info/'
,
api
.
RemoteAppConnectionInfoApi
.
as_view
(),
name
=
'remote-app-connection-info'
)
name
=
'remote-app-connection-info'
),
path
(
'databases/<uuid:pk>/auth-info/'
,
api
.
DatabaseAuthInfoApi
.
as_view
(),
name
=
'database-auth-info'
),
]
old_version_urlpatterns
=
[
re_path
(
'(?P<resource>remote-app|database)/.*'
,
capi
.
redirect_plural_name_api
)
...
...
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