File 0001-Fixed-the-LDAP-authentication-issue-for-the-simultaneous.patch of Package pgadmin4.38248
From fa29ba91632634d961f937ce3ed2c3b5a9d78f59 Mon Sep 17 00:00:00 2001
From: Khushboo Vashi <khushboo.vashi@enterprisedb.com>
Date: Tue, 4 Apr 2023 18:47:13 +0530
Subject: [PATCH] Fixed the LDAP authentication issue for the simultaneous
login attempts.
---
web/pgadmin/authenticate/__init__.py | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/web/pgadmin/authenticate/__init__.py b/web/pgadmin/authenticate/__init__.py
index bda9dadbf0d..0d5b429c0df 100644
--- a/web/pgadmin/authenticate/__init__.py
+++ b/web/pgadmin/authenticate/__init__.py
@@ -12,6 +12,7 @@
from pgadmin.utils.csrf import pgCSRFProtect
from .registry import AuthSourceRegistry
+from threading import Lock
MODULE_NAME = 'authenticate'
@@ -35,6 +36,19 @@
return Response(render_template("browser/kerberos_logout.html",
login_url=url_for('security.login'),
))
+
+
+class AuthLocker:
+ """Implementing lock while authentication."""
+ lock = Lock()
+
+ def __enter__(self):
+ self.lock.acquire()
+ return self
+
+ def __exit__(self, type, value, traceback):
+ if self.lock.locked():
+ self.lock.release()
@blueprint.route('/login', endpoint='login', methods=['GET', 'POST'])
@@ -83,6 +97,14 @@ def login():
Entry point for all the authentication sources.
The user input will be validated and authenticated.
"""
+ with AuthLocker():
+ return _login()
+
+
+def _login():
+ """
+ Internal authentication process locked by a mutex.
+ """
form = _security.login_form()
auth_obj = AuthSourceManager(form, config.AUTHENTICATION_SOURCES)
session['_auth_source_manager_obj'] = None