diff --git a/apps/authentication/backends/ldap.py b/apps/authentication/backends/ldap.py index 49240f068..f802b5307 100644 --- a/apps/authentication/backends/ldap.py +++ b/apps/authentication/backends/ldap.py @@ -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): diff --git a/apps/authentication/backends/openid/backends.py b/apps/authentication/backends/openid/backends.py index aeb611db5..b8e4ae609 100644 --- a/apps/authentication/backends/openid/backends.py +++ b/apps/authentication/backends/openid/backends.py @@ -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