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
bd323d60
Commit
bd323d60
authored
Nov 08, 2019
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Update] 修改api
parent
f9e41d71
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
35 additions
and
21 deletions
+35
-21
login_confirm.py
apps/authentication/api/login_confirm.py
+2
-2
mfa.py
apps/authentication/api/mfa.py
+2
-0
token.py
apps/authentication/api/token.py
+2
-0
errors.py
apps/authentication/errors.py
+21
-12
login_wait_confirm.html
...tication/templates/authentication/login_wait_confirm.html
+8
-7
No files found.
apps/authentication/api/login_confirm.py
View file @
bd323d60
...
...
@@ -63,8 +63,8 @@ class LoginConfirmTicketStatusApi(APIView):
raise
errors
.
LoginConfirmOtherError
(
ticket_id
,
ticket
.
get_status_display
()
)
except
errors
.
AuthFailed
Error
as
e
:
return
Response
(
e
.
as_data
(),
status
=
4
00
)
except
errors
.
NeedMoreInfo
Error
as
e
:
return
Response
(
e
.
as_data
(),
status
=
2
00
)
def
delete
(
self
,
request
,
*
args
,
**
kwargs
):
ticket
=
self
.
get_ticket
()
...
...
apps/authentication/api/mfa.py
View file @
bd323d60
...
...
@@ -35,6 +35,8 @@ class MFAChallengeApi(AuthMixin, CreateAPIView):
except
errors
.
AuthFailedError
as
e
:
data
=
{
"error"
:
e
.
error
,
"msg"
:
e
.
msg
}
raise
ValidationError
(
data
)
except
errors
.
NeedMoreInfoError
as
e
:
return
Response
(
e
.
as_data
(),
status
=
200
)
def
create
(
self
,
request
,
*
args
,
**
kwargs
):
super
()
.
create
(
request
,
*
args
,
**
kwargs
)
...
...
apps/authentication/api/token.py
View file @
bd323d60
...
...
@@ -37,3 +37,5 @@ class TokenCreateApi(AuthMixin, CreateAPIView):
return
resp
except
errors
.
AuthFailedError
as
e
:
return
Response
(
e
.
as_data
(),
status
=
400
)
except
errors
.
NeedMoreInfoError
as
e
:
return
Response
(
e
.
as_data
(),
status
=
200
)
apps/authentication/errors.py
View file @
bd323d60
...
...
@@ -130,7 +130,24 @@ class SessionEmptyError(AuthFailedError):
error
=
'session_empty'
class
MFARequiredError
(
AuthFailedError
):
class
NeedMoreInfoError
(
Exception
):
error
=
''
msg
=
''
def
__init__
(
self
,
error
=
''
,
msg
=
''
):
if
error
:
self
.
error
=
error
if
msg
:
self
.
msg
=
''
def
as_data
(
self
):
return
{
'error'
:
self
.
error
,
'msg'
:
self
.
msg
,
}
class
MFARequiredError
(
NeedMoreInfoError
):
msg
=
mfa_required_msg
error
=
'mfa_required'
...
...
@@ -145,15 +162,7 @@ class MFARequiredError(AuthFailedError):
}
class
LoginConfirmRequiredError
(
AuthFailedError
):
msg
=
login_confirm_required_msg
error
=
'login_confirm_required'
class
LoginConfirmError
(
AuthFailedError
):
msg
=
login_confirm_wait_msg
error
=
'login_confirm_wait'
class
LoginConfirmBaseError
(
NeedMoreInfoError
):
def
__init__
(
self
,
ticket_id
,
**
kwargs
):
self
.
ticket_id
=
ticket_id
super
()
.
__init__
(
**
kwargs
)
...
...
@@ -168,12 +177,12 @@ class LoginConfirmError(AuthFailedError):
}
class
LoginConfirmWaitError
(
LoginConfirmError
):
class
LoginConfirmWaitError
(
LoginConfirm
Base
Error
):
msg
=
login_confirm_wait_msg
error
=
'login_confirm_wait'
class
LoginConfirmOtherError
(
LoginConfirmError
):
class
LoginConfirmOtherError
(
LoginConfirm
Base
Error
):
error
=
'login_confirm_error'
def
__init__
(
self
,
ticket_id
,
status
):
...
...
apps/authentication/templates/authentication/login_wait_confirm.html
View file @
bd323d60
...
...
@@ -80,12 +80,7 @@ function doRequestAuth() {
requestApi
({
url
:
url
,
method
:
"GET"
,
success
:
function
()
{
clearInterval
(
interval
);
clearInterval
(
checkInterval
);
window
.
location
=
successUrl
;
},
error
:
function
(
text
,
data
)
{
success
:
function
(
data
)
{
if
(
data
.
error
!==
"login_confirm_wait"
)
{
if
(
!
errorMsgShow
)
{
infoMsgRef
.
hide
();
...
...
@@ -97,7 +92,13 @@ function doRequestAuth() {
clearInterval
(
checkInterval
);
$
(
".copy-btn"
).
attr
(
'disabled'
,
'disabled'
)
}
errorMsgRef
.
html
(
data
.
msg
)
if
(
data
.
msg
===
'ok'
&&
!
data
.
error
)
{
window
.
location
=
"{% url 'authentication:login-guard' %}"
}
else
{
errorMsgRef
.
html
(
data
.
msg
)
}
},
error
:
function
(
text
,
data
)
{
},
flash_message
:
false
})
...
...
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