Spaces:
Paused
Paused
Download apps/renderer/config/auth.py from modventures/prevision: direct link, hf CLI and curl.
- Browser
- Download file 1.83 kB
-
https://huggingface.co/spaces/modventures/prevision/resolve/main/apps/renderer/config/auth.py
- Command line
-
hf download hf://spaces/modventures/prevision/apps/renderer/config/auth.py
-
curl -L -o auth.py https://huggingface.co/spaces/modventures/prevision/resolve/main/apps/renderer/config/auth.py
1.83 kB
| """Prevision renderer authentication and internal allowance service configuration.""" | |
| from config.loader import config_value | |
| AUTH_ENFORCEMENT = str(config_value("AUTH_ENFORCEMENT", "auth", "enforcement", "off")).strip().lower() | |
| if AUTH_ENFORCEMENT not in {"off", "on"}: | |
| raise RuntimeError("AUTH_ENFORCEMENT must be 'off' or 'on'") | |
| AUTH_ENFORCED = AUTH_ENFORCEMENT == "on" | |
| PROCESSING_TOKEN_SECRET = str(config_value("PROCESSING_TOKEN_SECRET", "auth", "processing_token_secret", "")) | |
| PROCESSING_TOKEN_AUDIENCE = str(config_value( | |
| "PROCESSING_TOKEN_AUDIENCE", "auth", "processing_token_audience", "prevision-processing", | |
| )) | |
| TOKEN_ISSUER = str(config_value("TOKEN_ISSUER", "auth", "token_issuer", "prevision-api")) | |
| # The Prevision API (apps/prevision-api) issues processing tokens. Its users have free | |
| # tries: each accepted job is charged to that API, and refunded if it fails. | |
| PREVISION_TOKEN_ISSUER = "prevision-api" | |
| TOKEN_ISSUERS = (TOKEN_ISSUER,) | |
| PREVISION_API_INTERNAL_URL = str(config_value( | |
| "PREVISION_API_INTERNAL_URL", "auth", "prevision_api_internal_url", "http://127.0.0.1:8001", | |
| )).rstrip("/") | |
| PREVISION_INTERNAL_AUDIENCE = "prevision-internal" | |
| # Allowed clock drift between the account API and this service. | |
| TOKEN_LEEWAY_SECONDS = int(config_value("TOKEN_LEEWAY_SECONDS", "auth", "token_leeway_seconds", "30")) | |
| if AUTH_ENFORCED and len(PROCESSING_TOKEN_SECRET) < 32: | |
| raise RuntimeError("AUTH_ENFORCEMENT=on requires PROCESSING_TOKEN_SECRET (32+ characters)") | |
| # Comma-separated browser origins. Tokens travel in the Authorization header, | |
| # never in cookies, so a wildcard does not expose ambient credentials. | |
| CORS_ALLOWED_ORIGINS = [ | |
| origin.strip().rstrip("/") | |
| for origin in str(config_value("CORS_ALLOWED_ORIGINS", "auth", "cors_allowed_origins", "*")).split(",") | |
| if origin.strip() | |
| ] | |