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
904f6460
Commit
904f6460
authored
Feb 28, 2019
by
BaiJiangJie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Bugfix] 修复authentication模块之间引用的bug
parent
9b350920
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
12 additions
and
11 deletions
+12
-11
ldap.py
apps/authentication/backends/ldap.py
+2
-0
models.py
apps/authentication/backends/openid/models.py
+3
-7
views.py
apps/authentication/backends/openid/views.py
+1
-1
api_urls.py
apps/authentication/urls/api_urls.py
+1
-0
view_urls.py
apps/authentication/urls/view_urls.py
+2
-0
settings.py
apps/jumpserver/settings.py
+2
-2
login.html
apps/users/templates/users/login.html
+1
-1
No files found.
apps/authentication/backends/ldap.py
View file @
904f6460
...
@@ -16,6 +16,8 @@ class LDAPAuthorizationBackend(LDAPBackend):
...
@@ -16,6 +16,8 @@ class LDAPAuthorizationBackend(LDAPBackend):
"""
"""
def
authenticate
(
self
,
request
=
None
,
username
=
None
,
password
=
None
,
**
kwargs
):
def
authenticate
(
self
,
request
=
None
,
username
=
None
,
password
=
None
,
**
kwargs
):
if
not
username
:
return
None
ldap_user
=
LDAPUser
(
self
,
username
=
username
.
strip
(),
request
=
request
)
ldap_user
=
LDAPUser
(
self
,
username
=
username
.
strip
(),
request
=
request
)
user
=
self
.
authenticate_ldap_user
(
ldap_user
,
password
)
user
=
self
.
authenticate_ldap_user
(
ldap_user
,
password
)
return
user
return
user
...
...
apps/authentication/backends/openid/models.py
View file @
904f6460
...
@@ -39,10 +39,6 @@ class Client(object):
...
@@ -39,10 +39,6 @@ class Client(object):
self
.
openid_connect_client
=
self
.
new_openid_connect_client
()
self
.
openid_connect_client
=
self
.
new_openid_connect_client
()
def
new_realm
(
self
):
def
new_realm
(
self
):
"""
:param authentication.openid.models.Realm realm:
:return keycloak.realm.Realm:
"""
return
KeycloakRealm
(
return
KeycloakRealm
(
server_url
=
self
.
server_url
,
server_url
=
self
.
server_url
,
realm_name
=
self
.
realm_name
,
realm_name
=
self
.
realm_name
,
...
@@ -77,7 +73,7 @@ class Client(object):
...
@@ -77,7 +73,7 @@ class Client(object):
:param str username: authentication username
:param str username: authentication username
:param str password: authentication password
:param str password: authentication password
:return:
authentication.models.
OpenIDTokenProfile
:return: OpenIDTokenProfile
"""
"""
token_response
=
self
.
openid_client
.
token
(
token_response
=
self
.
openid_client
.
token
(
username
=
username
,
password
=
password
username
=
username
,
password
=
password
...
@@ -94,7 +90,7 @@ class Client(object):
...
@@ -94,7 +90,7 @@ class Client(object):
:param str code: authentication code
:param str code: authentication code
:param str redirect_uri:
:param str redirect_uri:
:rtype:
authentication.models.
OpenIDTokenProfile
:rtype: OpenIDTokenProfile
"""
"""
token_response
=
self
.
openid_connect_client
.
authorization_code
(
token_response
=
self
.
openid_connect_client
.
authorization_code
(
...
@@ -115,7 +111,7 @@ class Client(object):
...
@@ -115,7 +111,7 @@ class Client(object):
- refresh_expires_in
- refresh_expires_in
:param dict token_response:
:param dict token_response:
:rtype:
authentication.openid.models.
OpenIDTokenProfile
:rtype: OpenIDTokenProfile
"""
"""
userinfo
=
self
.
openid_connect_client
.
userinfo
(
userinfo
=
self
.
openid_connect_client
.
userinfo
(
...
...
apps/authentication/backends/openid/views.py
View file @
904f6460
...
@@ -27,7 +27,7 @@ class OpenIDLoginView(RedirectView):
...
@@ -27,7 +27,7 @@ class OpenIDLoginView(RedirectView):
def
get_redirect_url
(
self
,
*
args
,
**
kwargs
):
def
get_redirect_url
(
self
,
*
args
,
**
kwargs
):
# Todo: 待优化
# Todo: 待优化
redirect_uri
=
settings
.
BASE_SITE_URL
+
s
ettings
.
LOGIN_COMPLETE_URL
redirect_uri
=
settings
.
BASE_SITE_URL
+
s
tr
(
settings
.
LOGIN_COMPLETE_URL
)
nonce
=
Nonce
(
nonce
=
Nonce
(
redirect_uri
=
redirect_uri
,
redirect_uri
=
redirect_uri
,
next_path
=
self
.
request
.
GET
.
get
(
'next'
)
next_path
=
self
.
request
.
GET
.
get
(
'next'
)
...
...
apps/authentication/urls/api_urls.py
View file @
904f6460
# coding:utf-8
# coding:utf-8
#
#
from
__future__
import
absolute_import
from
__future__
import
absolute_import
from
django.urls
import
path
from
django.urls
import
path
...
...
apps/authentication/urls/view_urls.py
View file @
904f6460
# coding:utf-8
# coding:utf-8
#
#
from
__future__
import
absolute_import
from
django.urls
import
path
,
include
from
django.urls
import
path
,
include
from
..
import
views
from
..
import
views
...
...
apps/jumpserver/settings.py
View file @
904f6460
...
@@ -395,7 +395,7 @@ AUTH_LDAP_CONNECTION_OPTIONS = {
...
@@ -395,7 +395,7 @@ AUTH_LDAP_CONNECTION_OPTIONS = {
}
}
AUTH_LDAP_GROUP_CACHE_TIMEOUT
=
1
AUTH_LDAP_GROUP_CACHE_TIMEOUT
=
1
AUTH_LDAP_ALWAYS_UPDATE_USER
=
True
AUTH_LDAP_ALWAYS_UPDATE_USER
=
True
AUTH_LDAP_BACKEND
=
'authentication.
ldap.backends
.LDAPAuthorizationBackend'
AUTH_LDAP_BACKEND
=
'authentication.
backends.ldap
.LDAPAuthorizationBackend'
if
AUTH_LDAP
:
if
AUTH_LDAP
:
AUTHENTICATION_BACKENDS
.
insert
(
0
,
AUTH_LDAP_BACKEND
)
AUTHENTICATION_BACKENDS
.
insert
(
0
,
AUTH_LDAP_BACKEND
)
...
@@ -421,7 +421,7 @@ if AUTH_OPENID:
...
@@ -421,7 +421,7 @@ if AUTH_OPENID:
# Radius Auth
# Radius Auth
AUTH_RADIUS
=
CONFIG
.
AUTH_RADIUS
AUTH_RADIUS
=
CONFIG
.
AUTH_RADIUS
AUTH_RADIUS_BACKEND
=
'authentication.
radius.backend
s.RadiusBackend'
AUTH_RADIUS_BACKEND
=
'authentication.
backends.radiu
s.RadiusBackend'
RADIUS_SERVER
=
CONFIG
.
RADIUS_SERVER
RADIUS_SERVER
=
CONFIG
.
RADIUS_SERVER
RADIUS_PORT
=
CONFIG
.
RADIUS_PORT
RADIUS_PORT
=
CONFIG
.
RADIUS_PORT
RADIUS_SECRET
=
CONFIG
.
RADIUS_SECRET
RADIUS_SECRET
=
CONFIG
.
RADIUS_SECRET
...
...
apps/users/templates/users/login.html
View file @
904f6460
...
@@ -88,7 +88,7 @@
...
@@ -88,7 +88,7 @@
<div
class=
"hr-line-dashed"
></div>
<div
class=
"hr-line-dashed"
></div>
<p
class=
"text-muted text-center"
>
{% trans "More login options" %}
</p>
<p
class=
"text-muted text-center"
>
{% trans "More login options" %}
</p>
<div>
<div>
<button
type=
"button"
class=
"btn btn-default btn-sm btn-block"
onclick=
"location.href='{% url 'authentication:openid-login' %}'"
>
<button
type=
"button"
class=
"btn btn-default btn-sm btn-block"
onclick=
"location.href='{% url 'authentication:openid
:openid
-login' %}'"
>
<i
class=
"fa fa-openid"
></i>
<i
class=
"fa fa-openid"
></i>
{% trans 'Keycloak' %}
{% trans 'Keycloak' %}
</button>
</button>
...
...
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