mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-10 07:26:01 -06:00
Add additional logging for successful logins and user creation. #5842
This commit is contained in:
parent
ed2b8ea1de
commit
83ec0f3d90
@ -78,6 +78,8 @@ class BaseAuthentication(metaclass=AuthSourceRegistry):
|
||||
if not status:
|
||||
current_app.logger.exception(self.messages('LOGIN_FAILED'))
|
||||
return False, self.messages('LOGIN_FAILED')
|
||||
current_app.logger.info(
|
||||
"Internal user {0} logged in.".format(username))
|
||||
return True, None
|
||||
|
||||
def messages(self, msg_key):
|
||||
|
@ -273,6 +273,10 @@ class KerberosAuthentication(BaseAuthentication):
|
||||
user = User.query.filter_by(
|
||||
username=username, auth_source=KERBEROS).first()
|
||||
if user is None:
|
||||
create_msg = ("Creating user {0} with email {1} "
|
||||
"from auth source KERBEROS.")
|
||||
current_app.logger.info(create_msg.format(username,
|
||||
username))
|
||||
return create_user({
|
||||
'username': username,
|
||||
'email': username,
|
||||
|
@ -175,6 +175,8 @@ class LDAPAuthentication(BaseAuthentication):
|
||||
if not status:
|
||||
current_app.logger.exception(self.messages('LOGIN_FAILED'))
|
||||
return False, self.messages('LOGIN_FAILED')
|
||||
current_app.logger.info(
|
||||
"LDAP user {0} logged in.".format(user))
|
||||
return True, None
|
||||
|
||||
def __auto_create_user(self, user_email):
|
||||
@ -188,6 +190,10 @@ class LDAPAuthentication(BaseAuthentication):
|
||||
self.username)).first()
|
||||
|
||||
if user is None:
|
||||
create_msg = ("Creating user {0} with email {1} "
|
||||
"from auth source LDAP.")
|
||||
current_app.logger.info(create_msg.format(self.username,
|
||||
user_email))
|
||||
return create_user({
|
||||
'username': self.username,
|
||||
'email': user_email,
|
||||
|
@ -157,6 +157,8 @@ class OAuth2Authentication(BaseAuthentication):
|
||||
username=username, auth_source=OAUTH2).first()
|
||||
current_app.login_manager.logout_view = \
|
||||
OAuth2Authentication.LOGOUT_VIEW
|
||||
current_app.logger.info(
|
||||
"OAUTH2 user {0} logged in.".format(username))
|
||||
return login_user(user), None
|
||||
return False, msg
|
||||
|
||||
@ -189,6 +191,10 @@ class OAuth2Authentication(BaseAuthentication):
|
||||
user = User.query.filter_by(username=username,
|
||||
auth_source=OAUTH2).first()
|
||||
if not user:
|
||||
create_msg = ("Creating user {0} with email {1} "
|
||||
"from auth source OAUTH2.")
|
||||
current_app.logger.info(create_msg.format(username,
|
||||
email))
|
||||
return create_user({
|
||||
'username': username,
|
||||
'email': email,
|
||||
|
@ -104,6 +104,8 @@ class WebserverAuthentication(BaseAuthentication):
|
||||
if not status:
|
||||
current_app.logger.exception(self.messages('LOGIN_FAILED'))
|
||||
return False, self.messages('LOGIN_FAILED')
|
||||
current_app.logger.info(
|
||||
"Webserver user {0} logged in.".format(username))
|
||||
return True, None
|
||||
return False, self.messages('LOGIN_FAILED')
|
||||
|
||||
@ -112,6 +114,10 @@ class WebserverAuthentication(BaseAuthentication):
|
||||
if config.WEBSERVER_AUTO_CREATE_USER:
|
||||
user = User.query.filter_by(username=username).first()
|
||||
if not user:
|
||||
create_msg = ("Creating user {0} with email {1} "
|
||||
"from auth source Webserver.")
|
||||
current_app.logger.info(create_msg.format(username,
|
||||
useremail))
|
||||
return create_user({
|
||||
'username': username,
|
||||
'email': useremail,
|
||||
|
Loading…
Reference in New Issue
Block a user