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
c86a036a
Commit
c86a036a
authored
Mar 07, 2019
by
BaiJiangJie
Committed by
老广
Mar 07, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Update] OpenID认证流程添加详细日志 (#2462)
* [Update] OpenID认证流程添加详细日志 * [Update] 优化日志格式
parent
8694511d
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
8 deletions
+13
-8
ldap.py
apps/authentication/backends/ldap.py
+3
-0
backends.py
apps/authentication/backends/openid/backends.py
+10
-8
No files found.
apps/authentication/backends/ldap.py
View file @
c86a036a
...
...
@@ -16,10 +16,13 @@ class LDAPAuthorizationBackend(LDAPBackend):
"""
def
authenticate
(
self
,
request
=
None
,
username
=
None
,
password
=
None
,
**
kwargs
):
logger
.
info
(
'Authentication LDAP backend'
)
if
not
username
:
logger
.
info
(
'Authenticate failed: username is None'
)
return
None
ldap_user
=
LDAPUser
(
self
,
username
=
username
.
strip
(),
request
=
request
)
user
=
self
.
authenticate_ldap_user
(
ldap_user
,
password
)
logger
.
info
(
'Authenticate user: {}'
.
format
(
user
))
return
user
def
get_user
(
self
,
user_id
):
...
...
apps/authentication/backends/openid/backends.py
View file @
c86a036a
...
...
@@ -42,40 +42,41 @@ class BaseOpenIDAuthorizationBackend(object):
class
OpenIDAuthorizationCodeBackend
(
BaseOpenIDAuthorizationBackend
):
def
authenticate
(
self
,
request
,
**
kwargs
):
logger
.
info
(
'
1.openid
code backend'
)
logger
.
info
(
'
Authentication OpenID
code backend'
)
code
=
kwargs
.
get
(
'code'
)
redirect_uri
=
kwargs
.
get
(
'redirect_uri'
)
if
not
code
or
not
redirect_uri
:
logger
.
info
(
'Authenticate failed: No code or No redirect uri'
)
return
None
try
:
oidt_profile
=
client
.
update_or_create_from_code
(
code
=
code
,
redirect_uri
=
redirect_uri
code
=
code
,
redirect_uri
=
redirect_uri
)
except
Exception
as
e
:
logger
.
error
(
e
)
logger
.
info
(
'Authenticate failed: get oidt_profile: {}'
.
format
(
e
)
)
else
:
# Check openid user single logout or not with access_token
request
.
session
[
OIDT_ACCESS_TOKEN
]
=
oidt_profile
.
access_token
user
=
oidt_profile
.
user
logger
.
info
(
'Authenticate success: user -> {}'
.
format
(
user
))
return
user
if
self
.
user_can_authenticate
(
user
)
else
None
class
OpenIDAuthorizationPasswordBackend
(
BaseOpenIDAuthorizationBackend
):
def
authenticate
(
self
,
request
,
username
=
None
,
password
=
None
,
**
kwargs
):
logger
.
info
(
'
2.openid
password backend'
)
logger
.
info
(
'
Authentication OpenID
password backend'
)
if
not
settings
.
AUTH_OPENID
:
logger
.
info
(
'Authenticate failed: AUTH_OPENID is False'
)
return
None
elif
not
username
:
logger
.
info
(
'Authenticate failed: Not username'
)
return
None
try
:
...
...
@@ -84,9 +85,10 @@ class OpenIDAuthorizationPasswordBackend(BaseOpenIDAuthorizationBackend):
)
except
Exception
as
e
:
logger
.
error
(
e
)
logger
.
info
(
'Authenticate failed: get oidt_profile: {}'
.
format
(
e
)
)
else
:
user
=
oidt_profile
.
user
logger
.
info
(
'Authenticate success: user -> {}'
.
format
(
user
))
return
user
if
self
.
user_can_authenticate
(
user
)
else
None
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