mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Ensure that the strings in the LDAP auth module are translatable. Fixes #6274
This commit is contained in:
parent
14dcb70b95
commit
437f0df0f3
@ -22,6 +22,7 @@ Bug fixes
|
|||||||
| `Issue #6076 <https://redmine.postgresql.org/issues/6076>`_ - Fixed an issue where correct error not thrown while importing servers and JSON file has incorrect/insufficient keys.
|
| `Issue #6076 <https://redmine.postgresql.org/issues/6076>`_ - Fixed an issue where correct error not thrown while importing servers and JSON file has incorrect/insufficient keys.
|
||||||
| `Issue #6082 <https://redmine.postgresql.org/issues/6082>`_ - Ensure that the user should not be to change the connection when a long query is running.
|
| `Issue #6082 <https://redmine.postgresql.org/issues/6082>`_ - Ensure that the user should not be to change the connection when a long query is running.
|
||||||
| `Issue #6220 <https://redmine.postgresql.org/issues/6220>`_ - Corrected the syntax for 'CREATE TRIGGER', use 'EXECUTE FUNCTION' instead of 'EXECUTE PROCEDURE' from v11 onwards.
|
| `Issue #6220 <https://redmine.postgresql.org/issues/6220>`_ - Corrected the syntax for 'CREATE TRIGGER', use 'EXECUTE FUNCTION' instead of 'EXECUTE PROCEDURE' from v11 onwards.
|
||||||
|
| `Issue #6274 <https://redmine.postgresql.org/issues/6274>`_ - Ensure that the strings in the LDAP auth module are translatable.
|
||||||
| `Issue #6293 <https://redmine.postgresql.org/issues/6293>`_ - Fixed an issue where the procedure creation is failed when providing the Volatility option.
|
| `Issue #6293 <https://redmine.postgresql.org/issues/6293>`_ - Fixed an issue where the procedure creation is failed when providing the Volatility option.
|
||||||
| `Issue #6325 <https://redmine.postgresql.org/issues/6325>`_ - Ensure that the file format for the storage manager should be 'All files' and for other dialogs, it should remember the last selected format.
|
| `Issue #6325 <https://redmine.postgresql.org/issues/6325>`_ - Ensure that the file format for the storage manager should be 'All files' and for other dialogs, it should remember the last selected format.
|
||||||
| `Issue #6327 <https://redmine.postgresql.org/issues/6327>`_ - Ensure that while comparing domains check function dependencies should be considered in schema diff.
|
| `Issue #6327 <https://redmine.postgresql.org/issues/6327>`_ - Ensure that while comparing domains check function dependencies should be considered in schema diff.
|
||||||
|
@ -13,7 +13,6 @@ import flask
|
|||||||
import pickle
|
import pickle
|
||||||
from flask import current_app, flash, Response, request, url_for,\
|
from flask import current_app, flash, Response, request, url_for,\
|
||||||
render_template
|
render_template
|
||||||
from flask_babelex import gettext
|
|
||||||
from flask_security import current_user
|
from flask_security import current_user
|
||||||
from flask_security.views import _security, _ctx
|
from flask_security.views import _security, _ctx
|
||||||
from flask_security.utils import config_value, get_post_logout_redirect, \
|
from flask_security.utils import config_value, get_post_logout_redirect, \
|
||||||
@ -90,7 +89,7 @@ def login():
|
|||||||
return flask.redirect('{0}?next={1}'.format(url_for(
|
return flask.redirect('{0}?next={1}'.format(url_for(
|
||||||
'authenticate.kerberos_login'), url_for('browser.index')))
|
'authenticate.kerberos_login'), url_for('browser.index')))
|
||||||
|
|
||||||
flash(gettext(msg), 'danger')
|
flash(msg, 'danger')
|
||||||
return flask.redirect(get_post_logout_redirect())
|
return flask.redirect(get_post_logout_redirect())
|
||||||
|
|
||||||
session['_auth_source_manager_obj'] = current_auth_obj
|
session['_auth_source_manager_obj'] = current_auth_obj
|
||||||
@ -98,7 +97,7 @@ def login():
|
|||||||
|
|
||||||
elif isinstance(msg, Response):
|
elif isinstance(msg, Response):
|
||||||
return msg
|
return msg
|
||||||
flash(gettext(msg), 'danger')
|
flash(msg, 'danger')
|
||||||
response = flask.redirect(get_post_logout_redirect())
|
response = flask.redirect(get_post_logout_redirect())
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
@ -26,7 +26,8 @@ from pgadmin.tools.user_management import create_user
|
|||||||
from pgadmin.utils.constants import LDAP
|
from pgadmin.utils.constants import LDAP
|
||||||
|
|
||||||
|
|
||||||
ERROR_SEARCHING_LDAP_DIRECTORY = "Error searching the LDAP directory: {}"
|
ERROR_SEARCHING_LDAP_DIRECTORY = gettext(
|
||||||
|
"Error searching the LDAP directory: {}")
|
||||||
|
|
||||||
|
|
||||||
class LDAPAuthentication(BaseAuthentication):
|
class LDAPAuthentication(BaseAuthentication):
|
||||||
@ -53,7 +54,8 @@ class LDAPAuthentication(BaseAuthentication):
|
|||||||
self.anonymous_bind = getattr(config, 'LDAP_ANONYMOUS_BIND', False)
|
self.anonymous_bind = getattr(config, 'LDAP_ANONYMOUS_BIND', False)
|
||||||
|
|
||||||
if self.bind_user and not self.bind_pass:
|
if self.bind_user and not self.bind_pass:
|
||||||
return False, "LDAP configuration error: Set the bind password."
|
return False, gettext(
|
||||||
|
"LDAP configuration error: Set the bind password.")
|
||||||
|
|
||||||
# if no dedicated ldap user is configured then use the login
|
# if no dedicated ldap user is configured then use the login
|
||||||
# username and password
|
# username and password
|
||||||
@ -121,17 +123,17 @@ class LDAPAuthentication(BaseAuthentication):
|
|||||||
except LDAPSocketOpenError as e:
|
except LDAPSocketOpenError as e:
|
||||||
current_app.logger.exception(
|
current_app.logger.exception(
|
||||||
"Error connecting to the LDAP server: {}\n".format(e))
|
"Error connecting to the LDAP server: {}\n".format(e))
|
||||||
return False, "Error connecting to the LDAP server:" \
|
return False, gettext("Error connecting to the LDAP server: {}\n"
|
||||||
" {}\n".format(e.args[0])
|
).format(e.args[0])
|
||||||
except LDAPBindError as e:
|
except LDAPBindError as e:
|
||||||
current_app.logger.exception(
|
current_app.logger.exception(
|
||||||
"Error binding to the LDAP server.")
|
"Error binding to the LDAP server.")
|
||||||
return False, "Error binding to the LDAP server."
|
return False, gettext("Error binding to the LDAP server.")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
current_app.logger.exception(
|
current_app.logger.exception(
|
||||||
"Error connecting to the LDAP server: {}\n".format(e))
|
"Error connecting to the LDAP server: {}\n".format(e))
|
||||||
return False, "Error connecting to the LDAP server:" \
|
return False, gettext("Error connecting to the LDAP server: {}\n"
|
||||||
" {}\n".format(e.args[0])
|
).format(e.args[0])
|
||||||
|
|
||||||
# Enable TLS if STARTTLS is configured
|
# Enable TLS if STARTTLS is configured
|
||||||
if self.start_tls:
|
if self.start_tls:
|
||||||
@ -140,7 +142,8 @@ class LDAPAuthentication(BaseAuthentication):
|
|||||||
except LDAPStartTLSError as e:
|
except LDAPStartTLSError as e:
|
||||||
current_app.logger.exception(
|
current_app.logger.exception(
|
||||||
"Error starting TLS: {}\n".format(e))
|
"Error starting TLS: {}\n".format(e))
|
||||||
return False, "Error starting TLS: {}\n".format(e.args[0])
|
return False, gettext("Error starting TLS: {}\n"
|
||||||
|
).format(e.args[0])
|
||||||
|
|
||||||
return True, None
|
return True, None
|
||||||
|
|
||||||
@ -179,7 +182,7 @@ class LDAPAuthentication(BaseAuthentication):
|
|||||||
except LDAPSSLConfigurationError as e:
|
except LDAPSSLConfigurationError as e:
|
||||||
current_app.logger.exception(
|
current_app.logger.exception(
|
||||||
"LDAP configuration error: {}\n".format(e))
|
"LDAP configuration error: {}\n".format(e))
|
||||||
return False, "LDAP configuration error: {}\n".format(
|
return False, gettext("LDAP configuration error: {}\n").format(
|
||||||
e.args[0])
|
e.args[0])
|
||||||
return True, tls
|
return True, tls
|
||||||
|
|
||||||
@ -194,7 +197,8 @@ class LDAPAuthentication(BaseAuthentication):
|
|||||||
tls = None
|
tls = None
|
||||||
|
|
||||||
if isinstance(uri, str):
|
if isinstance(uri, str):
|
||||||
return False, "LDAP configuration error: Set the proper LDAP URI."
|
return False, gettext(
|
||||||
|
"LDAP configuration error: Set the proper LDAP URI.")
|
||||||
|
|
||||||
if uri.scheme == 'ldaps' or config.LDAP_USE_STARTTLS:
|
if uri.scheme == 'ldaps' or config.LDAP_USE_STARTTLS:
|
||||||
status, tls = self.__configure_tls()
|
status, tls = self.__configure_tls()
|
||||||
@ -224,8 +228,8 @@ class LDAPAuthentication(BaseAuthentication):
|
|||||||
search_base_dn = config.LDAP_SEARCH_BASE_DN
|
search_base_dn = config.LDAP_SEARCH_BASE_DN
|
||||||
if (not search_base_dn or search_base_dn == '<Search-Base-DN>')\
|
if (not search_base_dn or search_base_dn == '<Search-Base-DN>')\
|
||||||
and (self.anonymous_bind or self.dedicated_user):
|
and (self.anonymous_bind or self.dedicated_user):
|
||||||
return False, "LDAP configuration error:" \
|
return False, gettext("LDAP configuration error: "
|
||||||
" Set the Search Domain."
|
"Set the Search Domain.")
|
||||||
elif not search_base_dn or search_base_dn == '<Search-Base-DN>':
|
elif not search_base_dn or search_base_dn == '<Search-Base-DN>':
|
||||||
search_base_dn = config.LDAP_BASE_DN
|
search_base_dn = config.LDAP_BASE_DN
|
||||||
|
|
||||||
@ -260,8 +264,8 @@ class LDAPAuthentication(BaseAuthentication):
|
|||||||
results = len(self.conn.entries)
|
results = len(self.conn.entries)
|
||||||
if results > 1:
|
if results > 1:
|
||||||
return False, ERROR_SEARCHING_LDAP_DIRECTORY.format(
|
return False, ERROR_SEARCHING_LDAP_DIRECTORY.format(
|
||||||
"More than one result found.")
|
gettext("More than one result found."))
|
||||||
elif results < 1:
|
elif results < 1:
|
||||||
return False, ERROR_SEARCHING_LDAP_DIRECTORY.format(
|
return False, ERROR_SEARCHING_LDAP_DIRECTORY.format(
|
||||||
"Could not find the specified user.")
|
gettext("Could not find the specified user."))
|
||||||
return True, self.conn.entries[0]
|
return True, self.conn.entries[0]
|
||||||
|
Loading…
Reference in New Issue
Block a user