Replace hardcoded Google OAuth + password auth registration with auto-discovered auth providers. Each provider in auth/<name>/provider.py implements AuthProvider ABC and is automatically registered at startup. - auth/__init__.py: AuthProvider ABC + discover_providers() scanner - auth/google/: Google OAuth provider (extracted from webapp/auth.py) - auth/password/: Email/password provider (delegates to webapp/password_auth) - auth/desktop/: Desktop JWT auth (API-only, not visible on login page) - webapp/auth.py: stripped to core infra (login_required, /login, /logout) - webapp/app.py: auto-discovery loop replaces manual blueprint registration - login.html: dynamic provider buttons via Jinja loop
53 lines
1.2 KiB
Python
53 lines
1.2 KiB
Python
"""
|
|
Desktop JWT authentication provider.
|
|
|
|
Wraps the existing webapp/desktop_auth.py blueprint.
|
|
This is NOT a login provider (no login button) - it provides
|
|
JWT-based API authentication for the native desktop application.
|
|
"""
|
|
|
|
import logging
|
|
|
|
from flask import Blueprint
|
|
|
|
from auth import AuthProvider
|
|
from webapp.config import Config
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
class DesktopAuthProvider(AuthProvider):
|
|
"""Desktop app JWT authentication provider."""
|
|
|
|
def get_name(self) -> str:
|
|
return "desktop"
|
|
|
|
def get_display_name(self) -> str:
|
|
return "Desktop App"
|
|
|
|
def get_blueprint(self) -> Blueprint:
|
|
from webapp.desktop_auth import desktop_bp
|
|
|
|
return desktop_bp
|
|
|
|
def get_login_button(self) -> dict:
|
|
return {
|
|
"text": "",
|
|
"url": "",
|
|
"icon_html": "",
|
|
"subtitle": "",
|
|
"order": 100,
|
|
"css_class": "",
|
|
"visible": False,
|
|
}
|
|
|
|
def is_available(self) -> bool:
|
|
return bool(Config.DESKTOP_JWT_SECRET)
|
|
|
|
def init_app(self, app) -> None:
|
|
"""No additional initialization needed."""
|
|
pass
|
|
|
|
|
|
# Module-level provider instance for auto-discovery
|
|
provider = DesktopAuthProvider()
|