mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2024-11-22 16:56:30 -06:00
Fixed the LDAP authentication issue for the simultaneous login attempts.
This commit is contained in:
parent
c1a022c40c
commit
fa29ba9163
@ -12,6 +12,7 @@
|
|||||||
import config
|
import config
|
||||||
import copy
|
import copy
|
||||||
import functools
|
import functools
|
||||||
|
from threading import Lock
|
||||||
|
|
||||||
from flask import current_app, flash, Response, request, url_for, \
|
from flask import current_app, flash, Response, request, url_for, \
|
||||||
session, redirect, render_template
|
session, redirect, render_template
|
||||||
@ -35,6 +36,19 @@ auth_obj = None
|
|||||||
_URL_WITH_NEXT_PARAM = "{0}?next={1}"
|
_URL_WITH_NEXT_PARAM = "{0}?next={1}"
|
||||||
|
|
||||||
|
|
||||||
|
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()
|
||||||
|
|
||||||
|
|
||||||
def get_logout_url() -> str:
|
def get_logout_url() -> str:
|
||||||
"""
|
"""
|
||||||
Returns the logout url based on the current authentication method.
|
Returns the logout url based on the current authentication method.
|
||||||
@ -83,6 +97,14 @@ def login():
|
|||||||
Entry point for all the authentication sources.
|
Entry point for all the authentication sources.
|
||||||
The user input will be validated and authenticated.
|
The user input will be validated and authenticated.
|
||||||
"""
|
"""
|
||||||
|
with AuthLocker():
|
||||||
|
return _login()
|
||||||
|
|
||||||
|
|
||||||
|
def _login():
|
||||||
|
"""
|
||||||
|
Internal authentication process locked by a mutex.
|
||||||
|
"""
|
||||||
form = _security.forms.get('login_form').cls(request.form)
|
form = _security.forms.get('login_form').cls(request.form)
|
||||||
if OAUTH2 in config.AUTHENTICATION_SOURCES \
|
if OAUTH2 in config.AUTHENTICATION_SOURCES \
|
||||||
and 'oauth2_button' in request.form:
|
and 'oauth2_button' in request.form:
|
||||||
|
Loading…
Reference in New Issue
Block a user