Skip to content

Commit d8ed75d

Browse files
Ensure correct custom SSL certificate passed in connection string. #8215
1 parent 4392b83 commit d8ed75d

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

web/pgadmin/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,7 @@ def before_request():
829829
# but the user session may still be active. Logout the user
830830
# to get the key again when login
831831
if config.SERVER_MODE and current_user.is_authenticated and \
832-
app.PGADMIN_EXTERNAL_AUTH_SOURCE not in [
832+
session['auth_source_manager']['current_source'] not in [
833833
KERBEROS, OAUTH2, WEBSERVER] and \
834834
current_app.keyManager.get() is None and \
835835
request.endpoint not in ('security.login', 'security.logout'):
@@ -915,6 +915,10 @@ def all_exception_handler(e):
915915
@app.errorhandler(HTTPException)
916916
def http_exception_handler(e):
917917
current_app.logger.error(e, exc_info=True)
918+
if e.code == 400 and\
919+
e.description == 'The CSRF session token is missing.':
920+
error = str(e.description) + 'Please refresh the page.'
921+
return internal_server_error(errormsg=gettext(error))
918922
return e
919923

920924
# Intialize the key manager

web/pgadmin/utils/driver/psycopg3/server_manager.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -673,13 +673,11 @@ def create_connection_string(self, database, user, password=None):
673673
orig_value = value
674674
# Getting complete file path if the key is one of the below.
675675
if key in ['passfile', 'sslcert', 'sslkey','sslcrl',
676-
'sslcrldir']:
676+
'sslcrldir'] or \
677+
(key == 'sslrootcert' and value != 'system'):
677678
with_complete_path = True
678679
value = get_complete_file_path(value)
679680

680-
if key == 'sslrootcert' and value != 'system':
681-
dsn_args[key] = get_complete_file_path(value)
682-
683681
# If key is hostaddr and ssh tunnel is in use don't overwrite.
684682
if key == 'hostaddr' and self.use_ssh_tunnel:
685683
continue

0 commit comments

Comments
 (0)