diff --git a/apps/authentication/backends/ldap.py b/apps/authentication/backends/ldap.py index 7fcccc046..49240f068 100644 --- a/apps/authentication/backends/ldap.py +++ b/apps/authentication/backends/ldap.py @@ -16,6 +16,8 @@ class LDAPAuthorizationBackend(LDAPBackend): """ def authenticate(self, request=None, username=None, password=None, **kwargs): + if not username: + return None ldap_user = LDAPUser(self, username=username.strip(), request=request) user = self.authenticate_ldap_user(ldap_user, password) return user diff --git a/apps/authentication/backends/openid/models.py b/apps/authentication/backends/openid/models.py index 456c25b62..fd75ed870 100644 --- a/apps/authentication/backends/openid/models.py +++ b/apps/authentication/backends/openid/models.py @@ -39,10 +39,6 @@ class Client(object): self.openid_connect_client = self.new_openid_connect_client() def new_realm(self): - """ - :param authentication.openid.models.Realm realm: - :return keycloak.realm.Realm: - """ return KeycloakRealm( server_url=self.server_url, realm_name=self.realm_name, @@ -77,7 +73,7 @@ class Client(object): :param str username: authentication username :param str password: authentication password - :return: authentication.models.OpenIDTokenProfile + :return: OpenIDTokenProfile """ token_response = self.openid_client.token( username=username, password=password @@ -94,7 +90,7 @@ class Client(object): :param str code: authentication code :param str redirect_uri: - :rtype: authentication.models.OpenIDTokenProfile + :rtype: OpenIDTokenProfile """ token_response = self.openid_connect_client.authorization_code( @@ -115,7 +111,7 @@ class Client(object): - refresh_expires_in :param dict token_response: - :rtype: authentication.openid.models.OpenIDTokenProfile + :rtype: OpenIDTokenProfile """ userinfo = self.openid_connect_client.userinfo( diff --git a/apps/authentication/backends/openid/views.py b/apps/authentication/backends/openid/views.py index 60e001434..14eedf781 100644 --- a/apps/authentication/backends/openid/views.py +++ b/apps/authentication/backends/openid/views.py @@ -27,7 +27,7 @@ class OpenIDLoginView(RedirectView): def get_redirect_url(self, *args, **kwargs): # Todo: 待优化 - redirect_uri = settings.BASE_SITE_URL + settings.LOGIN_COMPLETE_URL + redirect_uri = settings.BASE_SITE_URL + str(settings.LOGIN_COMPLETE_URL) nonce = Nonce( redirect_uri=redirect_uri, next_path=self.request.GET.get('next') diff --git a/apps/authentication/urls/api_urls.py b/apps/authentication/urls/api_urls.py index f87f04613..b22c49884 100644 --- a/apps/authentication/urls/api_urls.py +++ b/apps/authentication/urls/api_urls.py @@ -1,5 +1,6 @@ # coding:utf-8 # + from __future__ import absolute_import from django.urls import path diff --git a/apps/authentication/urls/view_urls.py b/apps/authentication/urls/view_urls.py index 592a9dfb3..8602daca5 100644 --- a/apps/authentication/urls/view_urls.py +++ b/apps/authentication/urls/view_urls.py @@ -1,6 +1,8 @@ # coding:utf-8 # +from __future__ import absolute_import + from django.urls import path, include from .. import views diff --git a/apps/jumpserver/settings.py b/apps/jumpserver/settings.py index 0088bc35b..b826d3805 100644 --- a/apps/jumpserver/settings.py +++ b/apps/jumpserver/settings.py @@ -395,7 +395,7 @@ AUTH_LDAP_CONNECTION_OPTIONS = { } AUTH_LDAP_GROUP_CACHE_TIMEOUT = 1 AUTH_LDAP_ALWAYS_UPDATE_USER = True -AUTH_LDAP_BACKEND = 'authentication.ldap.backends.LDAPAuthorizationBackend' +AUTH_LDAP_BACKEND = 'authentication.backends.ldap.LDAPAuthorizationBackend' if AUTH_LDAP: AUTHENTICATION_BACKENDS.insert(0, AUTH_LDAP_BACKEND) @@ -421,7 +421,7 @@ if AUTH_OPENID: # Radius Auth AUTH_RADIUS = CONFIG.AUTH_RADIUS -AUTH_RADIUS_BACKEND = 'authentication.radius.backends.RadiusBackend' +AUTH_RADIUS_BACKEND = 'authentication.backends.radius.RadiusBackend' RADIUS_SERVER = CONFIG.RADIUS_SERVER RADIUS_PORT = CONFIG.RADIUS_PORT RADIUS_SECRET = CONFIG.RADIUS_SECRET diff --git a/apps/users/templates/users/login.html b/apps/users/templates/users/login.html index b4241bb8c..beacbacb8 100644 --- a/apps/users/templates/users/login.html +++ b/apps/users/templates/users/login.html @@ -88,7 +88,7 @@

{% trans "More login options" %}

-