mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
[Authentication] Some of the base class functions are not static
function, but - methods. Hence - 'self' should be used, and not 'cls'. Also - use a constant for duplicate string literal in LDAP authentication implementation.
This commit is contained in:
parent
d226ffbd1f
commit
414e336852
@ -30,11 +30,11 @@ class BaseAuthentication(object):
|
||||
}
|
||||
|
||||
@abstractproperty
|
||||
def get_friendly_name(cls):
|
||||
def get_friendly_name(self):
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def authenticate(cls):
|
||||
def authenticate(self):
|
||||
pass
|
||||
|
||||
def validate(self, form):
|
||||
@ -80,7 +80,7 @@ class BaseAuthentication(object):
|
||||
|
||||
class InternalAuthentication(BaseAuthentication):
|
||||
|
||||
def get_friendly_name(cls):
|
||||
def get_friendly_name(self):
|
||||
return gettext("internal")
|
||||
|
||||
def validate(self, form):
|
||||
|
@ -19,7 +19,6 @@ from flask_babelex import gettext
|
||||
|
||||
from .internal import BaseAuthentication
|
||||
from pgadmin.model import User, ServerGroup, db, Role
|
||||
from flask_security import login_user
|
||||
from flask import current_app
|
||||
from pgadmin.tools.user_management import create_user
|
||||
|
||||
@ -29,6 +28,11 @@ except ImportError:
|
||||
from urlparse import urlparse
|
||||
|
||||
|
||||
ERROR_SEARCHING_LDAP_DIRECTORY = gettext(
|
||||
"Error searching the LDAP directory: %s"
|
||||
)
|
||||
|
||||
|
||||
class LDAPAuthentication(BaseAuthentication):
|
||||
"""Ldap Authentication Class"""
|
||||
|
||||
@ -161,21 +165,20 @@ class LDAPAuthentication(BaseAuthentication):
|
||||
|
||||
except LDAPInvalidScopeError as e:
|
||||
current_app.logger.exception(
|
||||
"Error searching the LDAP directory: %s\n" % e)
|
||||
return False, "Error searching the LDAP directory:" \
|
||||
" %s\n" % e.args[0]
|
||||
gettext(ERROR_SEARCHING_LDAP_DIRECTORY) % e
|
||||
)
|
||||
return False, gettext(ERROR_SEARCHING_LDAP_DIRECTORY) % e.args[0]
|
||||
except LDAPAttributeError as e:
|
||||
current_app.logger.exception("Error searching the LDAP directory:"
|
||||
" %s\n" % e)
|
||||
return False, "Error searching the LDAP directory:" \
|
||||
" %s\n" % e.args[0]
|
||||
current_app.logger.exception(
|
||||
gettext(ERROR_SEARCHING_LDAP_DIRECTORY) % e
|
||||
)
|
||||
return False, gettext(ERROR_SEARCHING_LDAP_DIRECTORY) % e.args[0]
|
||||
except LDAPInvalidFilterError as e:
|
||||
current_app.logger.exception(
|
||||
"Error searching the LDAP directory: %s\n" % e)
|
||||
return False, "Error searching the LDAP directory:" \
|
||||
" %s\n" % e.args[0]
|
||||
gettext(ERROR_SEARCHING_LDAP_DIRECTORY) % e
|
||||
)
|
||||
return False, gettext(ERROR_SEARCHING_LDAP_DIRECTORY) % e.args[0]
|
||||
|
||||
users = []
|
||||
for entry in self.conn.entries:
|
||||
user_email = None
|
||||
if config.LDAP_USERNAME_ATTRIBUTE in entry and self.username == \
|
||||
|
Loading…
Reference in New Issue
Block a user