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
6 years ago
by
BaiJiangJie
Committed by
老广
6 years ago
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Update] OpenID认证流程添加详细日志 (#2462)
* [Update] OpenID认证流程添加详细日志 * [Update] 优化日志格式
parent
8694511d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
9 deletions
+14
-9
ldap.py
apps/authentication/backends/ldap.py
+3
-0
backends.py
apps/authentication/backends/openid/backends.py
+11
-9
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
):
...
...
This diff is collapsed.
Click to expand it.
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
This diff is collapsed.
Click to expand it.
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