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
edce831e
Commit
edce831e
authored
Nov 06, 2019
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Update] 修改api
parent
12e1e559
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
12 additions
and
8 deletions
+12
-8
signals_handler.py
apps/audits/signals_handler.py
+2
-2
login_confirm.py
apps/authentication/api/login_confirm.py
+1
-1
token.py
apps/authentication/api/token.py
+1
-1
errors.py
apps/authentication/errors.py
+7
-3
mixins.py
apps/authentication/mixins.py
+1
-0
signals_handler.py
apps/orders/signals_handler.py
+0
-1
No files found.
apps/audits/signals_handler.py
View file @
edce831e
...
@@ -108,10 +108,10 @@ def generate_data(username, request):
...
@@ -108,10 +108,10 @@ def generate_data(username, request):
user_agent
=
request
.
META
.
get
(
'HTTP_USER_AGENT'
,
''
)
user_agent
=
request
.
META
.
get
(
'HTTP_USER_AGENT'
,
''
)
if
isinstance
(
request
,
Request
):
if
isinstance
(
request
,
Request
):
login_ip
=
request
.
data
.
get
(
'remote_addr'
,
None
)
login_ip
=
request
.
data
.
get
(
'remote_addr'
,
'0.0.0.0'
)
login_type
=
request
.
data
.
get
(
'login_type'
,
''
)
login_type
=
request
.
data
.
get
(
'login_type'
,
''
)
else
:
else
:
login_ip
=
get_request_ip
(
request
)
login_ip
=
get_request_ip
(
request
)
or
'0.0.0.0'
login_type
=
'W'
login_type
=
'W'
data
=
{
data
=
{
...
...
apps/authentication/api/login_confirm.py
View file @
edce831e
...
@@ -50,7 +50,7 @@ class UserOrderAcceptAuthApi(APIView):
...
@@ -50,7 +50,7 @@ class UserOrderAcceptAuthApi(APIView):
elif
order
.
status
==
order
.
STATUS_REJECTED
:
elif
order
.
status
==
order
.
STATUS_REJECTED
:
raise
errors
.
LoginConfirmRejectedError
(
order_id
)
raise
errors
.
LoginConfirmRejectedError
(
order_id
)
else
:
else
:
r
eturn
errors
.
LoginConfirmWaitError
(
order_id
)
r
aise
errors
.
LoginConfirmWaitError
(
order_id
)
except
errors
.
AuthFailedError
as
e
:
except
errors
.
AuthFailedError
as
e
:
data
=
e
.
as_data
()
data
=
e
.
as_data
()
return
Response
(
data
,
status
=
400
)
return
Response
(
data
,
status
=
400
)
apps/authentication/api/token.py
View file @
edce831e
...
@@ -36,4 +36,4 @@ class TokenCreateApi(AuthMixin, CreateAPIView):
...
@@ -36,4 +36,4 @@ class TokenCreateApi(AuthMixin, CreateAPIView):
resp
=
super
()
.
create
(
request
,
*
args
,
**
kwargs
)
resp
=
super
()
.
create
(
request
,
*
args
,
**
kwargs
)
return
resp
return
resp
except
errors
.
AuthFailedError
as
e
:
except
errors
.
AuthFailedError
as
e
:
return
Response
(
e
.
as_data
(),
status
=
40
1
)
return
Response
(
e
.
as_data
(),
status
=
40
0
)
apps/authentication/errors.py
View file @
edce831e
...
@@ -139,8 +139,10 @@ class MFARequiredError(AuthFailedError):
...
@@ -139,8 +139,10 @@ class MFARequiredError(AuthFailedError):
return
{
return
{
'error'
:
self
.
error
,
'error'
:
self
.
error
,
'msg'
:
self
.
msg
,
'msg'
:
self
.
msg
,
'choices'
:
[
'otp'
],
'data'
:
{
'url'
:
reverse
(
'api-auth:mfa-challenge'
)
'choices'
:
[
'otp'
],
'url'
:
reverse
(
'api-auth:mfa-challenge'
)
}
}
}
...
@@ -161,7 +163,9 @@ class LoginConfirmError(AuthFailedError):
...
@@ -161,7 +163,9 @@ class LoginConfirmError(AuthFailedError):
return
{
return
{
"error"
:
self
.
error
,
"error"
:
self
.
error
,
"msg"
:
self
.
msg
,
"msg"
:
self
.
msg
,
"order_id"
:
self
.
order_id
"data"
:
{
"order_id"
:
self
.
order_id
}
}
}
...
...
apps/authentication/mixins.py
View file @
edce831e
...
@@ -114,6 +114,7 @@ class AuthMixin:
...
@@ -114,6 +114,7 @@ class AuthMixin:
self
.
request
.
session
[
'auth_password'
]
=
''
self
.
request
.
session
[
'auth_password'
]
=
''
self
.
request
.
session
[
'auth_mfa'
]
=
''
self
.
request
.
session
[
'auth_mfa'
]
=
''
self
.
request
.
session
[
'auth_confirm'
]
=
''
self
.
request
.
session
[
'auth_confirm'
]
=
''
self
.
request
.
session
[
'auth_order_id'
]
=
''
def
send_auth_signal
(
self
,
success
=
True
,
user
=
None
,
username
=
''
,
reason
=
''
):
def
send_auth_signal
(
self
,
success
=
True
,
user
=
None
,
username
=
''
,
reason
=
''
):
if
success
:
if
success
:
...
...
apps/orders/signals_handler.py
View file @
edce831e
...
@@ -20,7 +20,6 @@ def on_login_confirm_order_assignees_set(sender, instance=None, action=None,
...
@@ -20,7 +20,6 @@ def on_login_confirm_order_assignees_set(sender, instance=None, action=None,
if
action
==
'post_add'
:
if
action
==
'post_add'
:
logger
.
debug
(
'New order create, send mail: {}'
.
format
(
instance
.
id
))
logger
.
debug
(
'New order create, send mail: {}'
.
format
(
instance
.
id
))
assignees
=
model
.
objects
.
filter
(
pk__in
=
pk_set
)
assignees
=
model
.
objects
.
filter
(
pk__in
=
pk_set
)
print
(
assignees
)
send_login_confirm_order_mail_to_assignees
(
instance
,
assignees
)
send_login_confirm_order_mail_to_assignees
(
instance
,
assignees
)
...
...
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