Add auth.disabled_providers config to skip auth providers
Reads disabled_providers list from instance.yaml auth section. Listed providers are skipped during auto-discovery.
This commit is contained in:
parent
954aa0f17e
commit
91a05a2c2b
2 changed files with 12 additions and 1 deletions
|
|
@ -68,7 +68,11 @@ def discover_providers() -> list[AuthProvider]:
|
||||||
Each provider module must export a `provider` instance of AuthProvider.
|
Each provider module must export a `provider` instance of AuthProvider.
|
||||||
Providers are sorted by login button order.
|
Providers are sorted by login button order.
|
||||||
Only available providers (is_available() == True) are returned.
|
Only available providers (is_available() == True) are returned.
|
||||||
|
Providers listed in Config.AUTH_DISABLED_PROVIDERS are skipped.
|
||||||
"""
|
"""
|
||||||
|
from webapp.config import Config
|
||||||
|
|
||||||
|
disabled = [name.lower() for name in (Config.AUTH_DISABLED_PROVIDERS or [])]
|
||||||
providers = []
|
providers = []
|
||||||
auth_dir = Path(__file__).parent
|
auth_dir = Path(__file__).parent
|
||||||
|
|
||||||
|
|
@ -83,7 +87,11 @@ def discover_providers() -> list[AuthProvider]:
|
||||||
mod = importlib.import_module(f"auth.{subdir.name}.provider")
|
mod = importlib.import_module(f"auth.{subdir.name}.provider")
|
||||||
provider_instance = getattr(mod, "provider", None)
|
provider_instance = getattr(mod, "provider", None)
|
||||||
if provider_instance and isinstance(provider_instance, AuthProvider):
|
if provider_instance and isinstance(provider_instance, AuthProvider):
|
||||||
if provider_instance.is_available():
|
if provider_instance.get_name().lower() in disabled:
|
||||||
|
logger.info(
|
||||||
|
f"Auth provider disabled by config: {provider_instance.get_name()}"
|
||||||
|
)
|
||||||
|
elif provider_instance.is_available():
|
||||||
providers.append(provider_instance)
|
providers.append(provider_instance)
|
||||||
logger.info(f"Auth provider loaded: {provider_instance.get_name()}")
|
logger.info(f"Auth provider loaded: {provider_instance.get_name()}")
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -112,6 +112,9 @@ class Config:
|
||||||
THEME_PRIMARY_DARK = _get(_instance, "theme", "primary_dark", default="")
|
THEME_PRIMARY_DARK = _get(_instance, "theme", "primary_dark", default="")
|
||||||
THEME_PRIMARY_LIGHT = _get(_instance, "theme", "primary_light", default="")
|
THEME_PRIMARY_LIGHT = _get(_instance, "theme", "primary_light", default="")
|
||||||
|
|
||||||
|
# Auth providers to disable (list of provider names, e.g., ["email", "password"])
|
||||||
|
AUTH_DISABLED_PROVIDERS = _get(_instance, "auth", "disabled_providers", default=[])
|
||||||
|
|
||||||
# Telegram bot
|
# Telegram bot
|
||||||
TELEGRAM_BOT_USERNAME = _get(_instance, "telegram", "bot_username", default="")
|
TELEGRAM_BOT_USERNAME = _get(_instance, "telegram", "bot_username", default="")
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue