Buckets:
AnonymousSpottedToad/candidate_bucket / codebase /python /MarkinHaus_ToolBoxV2 /toolboxv2 /mods /CloudM /auth /config.py
| """ | |
| Environment and configuration for the auth system. | |
| """ | |
| import os | |
| # =================== Constants =================== | |
| JWT_ALGORITHM = "HS256" | |
| ACCESS_TOKEN_EXPIRY = 15 * 60 # 15 minutes | |
| REFRESH_TOKEN_EXPIRY = 7 * 24 * 3600 # 7 days | |
| STATE_EXPIRY = 10 * 60 # 10 minutes for OAuth state | |
| CHALLENGE_EXPIRY = 5 * 60 # 5 minutes for WebAuthn challenges | |
| MAGIC_LINK_EXPIRY = 10 * 60 # 10 minutes for magic links | |
| DEVICE_INVITE_EXPIRY = 5 * 60 # 5 minutes for device invites | |
| # =================== Environment Helpers =================== | |
| def is_production() -> bool: | |
| return os.getenv("TB_ENV", "development").lower() == "production" | |
| def get_jwt_secret() -> str: | |
| secret = os.getenv("TB_JWT_SECRET") or os.getenv("TB_COOKIE_SECRET") | |
| if secret: | |
| return secret | |
| # ponytail: no secret set -> auto-generate + persist instead of crashing | |
| # login on a fresh install. Production should still set TB_JWT_SECRET | |
| # explicitly; in production we refuse the autogen fallback. | |
| if is_production(): | |
| raise ValueError("TB_JWT_SECRET or TB_COOKIE_SECRET not set") | |
| from toolboxv2.init_onboarding import ensure_secret | |
| return ensure_secret() | |
| def get_base_url() -> str: | |
| if is_production(): | |
| return os.getenv("APP_BASE_URL_PROD", "https://simplecore.app") | |
| return os.getenv("APP_BASE_URL", "http://localhost:8467") | |
| def get_discord_config() -> dict: | |
| return { | |
| "client_id": os.getenv("DISCORD_CLIENT_ID", ""), | |
| "client_secret": os.getenv("DISCORD_CLIENT_SECRET", ""), | |
| "redirect_uri": os.getenv("DISCORD_REDIRECT_URI", f"{get_base_url()}/auth/discord/callback"), | |
| "scopes": ["identify", "email"], | |
| "authorize_url": "https://discord.com/api/oauth2/authorize", | |
| "token_url": "https://discord.com/api/oauth2/token", | |
| "user_url": "https://discord.com/api/users/@me", | |
| } | |
| def get_google_config() -> dict: | |
| return { | |
| "client_id": os.getenv("GOOGLE_CLIENT_ID", ""), | |
| "client_secret": os.getenv("GOOGLE_CLIENT_SECRET", ""), | |
| "redirect_uri": os.getenv("GOOGLE_REDIRECT_URI", f"{get_base_url()}/auth/google/callback"), | |
| "scopes": ["openid", "email", "profile"], | |
| "authorize_url": "https://accounts.google.com/o/oauth2/v2/auth", | |
| "token_url": "https://oauth2.googleapis.com/token", | |
| "user_url": "https://www.googleapis.com/oauth2/v2/userinfo", | |
| } | |
| def get_passkey_config() -> dict: | |
| rp_id = os.getenv("PASSKEY_RP_ID") | |
| if not rp_id: | |
| base = get_base_url() | |
| rp_id = base.replace("https://", "").replace("http://", "").split(":")[0] | |
| return { | |
| "rp_id": rp_id, | |
| "rp_name": os.getenv("PASSKEY_RP_NAME", "ToolBoxV2"), | |
| "origin": os.getenv("PASSKEY_ORIGIN", get_base_url()), | |
| } | |
| # =================== Local Admin (zero-friction local root) =================== | |
| LOCAL_ADMIN_EMAIL = "local-admin@toolbox.local" | |
| LOCAL_ADMIN_USERNAME = "root" | |
Xet Storage Details
- Size:
- 2.98 kB
- Xet hash:
- 75bbf3e662754207c68e6f5bd5674fa973b1374f9b89947f9ca3d4ea866854ab
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.