SFM/app/auth/providers.py
2026-06-04 16:45:18 +03:00

38 lines
1.1 KiB
Python

from __future__ import annotations
from typing import Any, Protocol
from .mock_provider import get_jwt_token as get_jwt_token_local
from .mock_provider import protect_application as protect_application_local
class AuthProvider(Protocol):
def get_token_data(self) -> dict[str, Any] | None: ...
class LocalMockProvider:
def get_token_data(self) -> dict[str, Any] | None:
protect_application_local(render_exit=False)
return get_jwt_token_local()
class RaisaProvider:
def get_token_data(self) -> dict[str, Any] | None:
from raisa_streamlit_oauth import ( # type: ignore[reportMissingImports]
get_jwt_token as get_jwt_token_raisa,
)
from raisa_streamlit_oauth import ( # type: ignore[reportMissingImports]
protect_application as protect_application_raisa,
)
protect_application_raisa(render_exit=False)
return get_jwt_token_raisa()
def build_auth_provider() -> AuthProvider:
if get_location() == "local":
return LocalMockProvider()
return RaisaProvider()