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
d80fec6e
Commit
d80fec6e
authored
Dec 27, 2016
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update some api
parent
d56f030d
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
28 additions
and
16 deletions
+28
-16
api.py
apps/applications/api.py
+13
-5
hands.py
apps/applications/hands.py
+2
-1
models.py
apps/applications/models.py
+1
-1
api_urls.py
apps/applications/urls/api_urls.py
+4
-2
views.py
apps/applications/views.py
+1
-0
api_urls.py
apps/assets/urls/api_urls.py
+4
-4
api_urls.py
apps/audits/urls/api_urls.py
+2
-2
permissions.py
apps/users/permissions.py
+1
-1
No files found.
apps/applications/api.py
View file @
d80fec6e
...
...
@@ -12,7 +12,7 @@ from rest_framework.decorators import api_view
from
.models
import
Terminal
,
TerminalHeatbeat
from
.serializers
import
TerminalSerializer
,
TerminalHeatbeatSerializer
from
.hands
import
IsSuperUserOrAppUser
,
User
from
.hands
import
IsSuperUserOrAppUser
,
IsAppUser
,
User
from
common.utils
import
get_object_or_none
...
...
@@ -39,7 +39,8 @@ class TerminalRegisterView(ListCreateAPIView):
data
[
'access_key_secret'
]
=
access_key
.
secret
return
Response
(
data
,
status
=
201
)
else
:
return
Response
(
serializer
.
errors
,
status
=
400
)
data
=
{
'msg'
:
'Not valid'
,
'detail'
:
';'
.
join
(
serializer
.
errors
)}
return
Response
(
data
,
status
=
400
)
def
list
(
self
,
request
,
*
args
,
**
kwargs
):
return
Response
(
''
,
status
=
404
)
...
...
@@ -57,10 +58,16 @@ class TerminalViewSet(viewsets.ModelViewSet):
class
TerminalHeatbeatViewSet
(
viewsets
.
ModelViewSet
):
queryset
=
TerminalHeatbeat
.
objects
.
all
()
serializer_class
=
TerminalHeatbeatSerializer
permission_classes
=
(
Is
SuperUserOr
AppUser
,)
permission_classes
=
(
IsAppUser
,)
def
create
(
self
,
request
,
*
args
,
**
kwargs
):
terminal
=
request
.
user
terminal
=
request
.
user
.
terminal
TerminalHeatbeat
.
objects
.
create
(
terminal
=
terminal
)
return
Response
({
'msg'
:
'Success'
})
return
Response
({
'msg'
:
'Success'
},
status
=
201
)
class
TestHeatbeat
(
APIView
):
permission_classes
=
(
IsAppUser
,)
def
post
(
self
,
request
):
return
Response
({
'hello'
:
'world'
})
\ No newline at end of file
apps/applications/hands.py
View file @
d80fec6e
...
...
@@ -2,5 +2,5 @@
#
from
users.models
import
User
from
users.permissions
import
IsSuperUserOrAppUser
from
users.permissions
import
IsSuperUserOrAppUser
,
IsAppUser
from
audits.models
import
ProxyLog
\ No newline at end of file
apps/applications/models.py
View file @
d80fec6e
...
...
@@ -14,7 +14,7 @@ class Terminal(models.Model):
name
=
models
.
CharField
(
max_length
=
30
,
unique
=
True
,
verbose_name
=
_
(
'Name'
))
remote_addr
=
models
.
GenericIPAddressField
(
verbose_name
=
_
(
'Remote address'
),
blank
=
True
,
null
=
True
)
type
=
models
.
CharField
(
choices
=
TYPE_CHOICES
,
max_length
=
3
,
blank
=
True
,
verbose_name
=
_
(
'Terminal type'
))
user
=
models
.
OneToOneField
(
User
,
verbose_name
=
'Application user'
,
null
=
True
)
user
=
models
.
OneToOneField
(
User
,
related_name
=
'terminal'
,
verbose_name
=
'Application user'
,
null
=
True
)
url
=
models
.
CharField
(
max_length
=
100
,
blank
=
True
,
verbose_name
=
_
(
'URL to login'
))
is_accepted
=
models
.
BooleanField
(
default
=
False
,
verbose_name
=
'Is Accepted'
)
date_created
=
models
.
DateTimeField
(
auto_now_add
=
True
)
...
...
apps/applications/urls/api_urls.py
View file @
d80fec6e
...
...
@@ -10,11 +10,12 @@ from .. import api
app_name
=
'applications'
router
=
routers
.
DefaultRouter
()
router
.
register
(
r'v1/terminal'
,
api
.
TerminalViewSet
,
'terminal'
)
router
.
register
(
r'v1/terminal/heatbeat'
,
api
.
TerminalHeatbeatViewSet
,
'terminal-heatbeat'
)
router
.
register
(
r'v1/terminal'
,
api
.
TerminalViewSet
,
'terminal'
)
urlpatterns
=
[
url
(
r'v1/terminal/register$'
,
api
.
TerminalRegisterView
.
as_view
(),
name
=
'terminal-register'
)
url
(
r'^v1/terminal/register/$'
,
api
.
TerminalRegisterView
.
as_view
(),
name
=
'terminal-register'
),
# url(r'^v1/terminal/heatbeat/$', api.TestHeatbeat.as_view())
]
urlpatterns
+=
router
.
urls
\ No newline at end of file
apps/applications/views.py
View file @
d80fec6e
...
...
@@ -51,6 +51,7 @@ class TerminalModelAccept(AdminUserRequiredMixin, JSONResponseMixin, UpdateView)
def
form_valid
(
self
,
form
):
terminal
=
form
.
save
()
terminal
.
is_accepted
=
True
terminal
.
is_active
=
True
terminal
.
save
()
data
=
{
'success'
:
True
,
...
...
apps/assets/urls/api_urls.py
View file @
d80fec6e
...
...
@@ -14,12 +14,12 @@ router.register(r'v1/admin-user', api.AdminUserViewSet, 'admin-user')
router
.
register
(
r'v1/system-user'
,
api
.
SystemUserViewSet
,
'system-user'
)
urlpatterns
=
[
url
(
r'^v1/assets_bulk$'
,
api
.
AssetListUpdateApi
.
as_view
(),
name
=
'asset-bulk-update'
),
url
(
r'^v1/assets_bulk
/
$'
,
api
.
AssetListUpdateApi
.
as_view
(),
name
=
'asset-bulk-update'
),
# url(r'^v1/idc/(?P<pk>[0-9]+)/assets/$', api.IDCAssetsApi.as_view(), name='api-idc-assets'),
url
(
r'^v1/system-user/auth'
,
api
.
SystemUserAuthApi
.
as_view
(),
name
=
'system-user-auth'
),
url
(
r'^v1/assets/(?P<pk>\d+)/groups$'
,
url
(
r'^v1/system-user/auth
/
'
,
api
.
SystemUserAuthApi
.
as_view
(),
name
=
'system-user-auth'
),
url
(
r'^v1/assets/(?P<pk>\d+)/groups
/
$'
,
api
.
AssetUpdateGroupApi
.
as_view
(),
name
=
'asset-update-group'
),
url
(
r'^v1/assets/(?P<pk>\d+)/system-users$'
,
url
(
r'^v1/assets/(?P<pk>\d+)/system-users
/
$'
,
api
.
SystemUserUpdateApi
.
as_view
(),
name
=
'asset-update-systemusers'
),
]
...
...
apps/audits/urls/api_urls.py
View file @
d80fec6e
...
...
@@ -7,8 +7,8 @@ app_name = 'audits'
router
=
routers
.
DefaultRouter
()
router
.
register
(
r'v1/proxy-log'
,
api
.
ProxyLogViewSet
,
'proxy-log'
)
router
.
register
(
r'v1/command-log'
,
api
.
CommandLogViewSet
,
'command-log'
)
router
.
register
(
r'v1/proxy-log
/
'
,
api
.
ProxyLogViewSet
,
'proxy-log'
)
router
.
register
(
r'v1/command-log
/
'
,
api
.
CommandLogViewSet
,
'command-log'
)
urlpatterns
=
router
.
urls
apps/users/permissions.py
View file @
d80fec6e
...
...
@@ -28,7 +28,7 @@ class IsAppUser(IsValidUser, permissions.BasePermission):
def
has_permission
(
self
,
request
,
view
):
return
super
(
IsAppUser
,
self
)
.
has_permission
(
request
,
view
)
\
and
request
.
user
.
is_app
()
and
request
.
user
.
is_app
class
IsSuperUser
(
IsValidUser
,
permissions
.
BasePermission
):
...
...
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