""" FastAPI router for authentication endpoints. """ from fastapi import APIRouter from fastapi.responses import JSONResponse from .. import environment_vars as env_vars from .. import logger from ..constants import Auth0 from ..responses import json_200_data logger = logger.new_logger(__name__) ROUTE: str = "/auth" def create_router(*args, **kwargs): """Create FastAPI router.""" app = APIRouter() @app.get("/config", response_class=JSONResponse) async def get_auth0_config(): """Returns the Auth0 tenant configuration. This endpoint is NOT protected by the Auth0 middleware, as it is used to retrieve the Auth0 configuration for the frontend, before the frontend attempts to authenticate with Auth0. The configuration settings are to be provided via environment variables """ credentials = {Auth0.CLIENT_ID, Auth0.CLIENT_SECRET} auth0_config = { k: v for k, v in env_vars.AUTH0_SETTINGS.items() if k not in credentials } return json_200_data(auth0_config) return app