mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2026-08-17 16:34:44 -05:00
Desktop mode has no use for the kerberos, ldap, mfa, oauth2 or webserver authentication providers: AUTHENTICATION_SOURCES defaults to internal, MFA is inert because mfa_enabled() requires SERVER_MODE, and get_logout_url() already guards its kerberos and oauth2 branches on SERVER_MODE. So skip importing and initialising them unless SERVER_MODE is set, leaving desktop mode with internal authentication alone. The accompanying test needed wiring into our own runner before it would ever execute: web/pgadmin/authenticate/tests/ had no __init__.py, so pkgutil did not report it and find_modules() never reached the module, and the test class derived from unittest.TestCase rather than BaseTestGenerator, so the TestsGeneratorRegistry metaclass never registered it and get_suite() could not pick it up. Both are fixed here, and the two scenarios now run and pass under regression/runtests.py. The test no longer asserts that pgadmin.authenticate.mfa is absent from sys.modules in desktop mode, because it is not: both pgadmin/browser/__init__ and pgadmin/user_login_check import pgadmin.authenticate.mfa.utils unconditionally. The original assertion only held because the test itself popped the module first.
48 lines
1.2 KiB
Python
48 lines
1.2 KiB
Python
##########################################################################
|
|
#
|
|
# pgAdmin 4 - PostgreSQL Tools
|
|
#
|
|
# Copyright (C) 2013 - 2026, The pgAdmin Development Team
|
|
# This software is released under the PostgreSQL Licence
|
|
#
|
|
##########################################################################
|
|
|
|
"""External Authentication Registry."""
|
|
|
|
|
|
import config
|
|
from pgadmin.utils.dynamic_registry import create_registry_metaclass
|
|
|
|
|
|
@classmethod
|
|
def load_modules(cls, app=None):
|
|
submodules = []
|
|
from . import internal as module
|
|
submodules.append(module)
|
|
|
|
if config.SERVER_MODE:
|
|
from . import kerberos as module
|
|
submodules.append(module)
|
|
|
|
from . import ldap as module
|
|
submodules.append(module)
|
|
|
|
from . import mfa as module
|
|
submodules.append(module)
|
|
|
|
from . import oauth2 as module
|
|
submodules.append(module)
|
|
|
|
from . import webserver as module
|
|
submodules.append(module)
|
|
|
|
for module in submodules:
|
|
if "init_app" in module.__dict__.keys():
|
|
module.__dict__["init_app"](app)
|
|
|
|
|
|
AuthSourceRegistry = create_registry_metaclass(
|
|
"AuthSourceRegistry", __package__, load_modules=load_modules,
|
|
decorate_as_module=True
|
|
)
|