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:
Petr 2026-03-11 12:54:23 +01:00
parent 954aa0f17e
commit 91a05a2c2b
2 changed files with 12 additions and 1 deletions

View file

@ -68,7 +68,11 @@ def discover_providers() -> list[AuthProvider]:
Each provider module must export a `provider` instance of AuthProvider.
Providers are sorted by login button order.
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 = []
auth_dir = Path(__file__).parent
@ -83,7 +87,11 @@ def discover_providers() -> list[AuthProvider]:
mod = importlib.import_module(f"auth.{subdir.name}.provider")
provider_instance = getattr(mod, "provider", None)
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)
logger.info(f"Auth provider loaded: {provider_instance.get_name()}")
else:

View file

@ -112,6 +112,9 @@ class Config:
THEME_PRIMARY_DARK = _get(_instance, "theme", "primary_dark", 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_USERNAME = _get(_instance, "telegram", "bot_username", default="")