Coverage for webapp/config.py: 94%
32 statements
« prev ^ index » next coverage.py v7.15.0, created at 2026-07-08 12:33 +0000
« prev ^ index » next coverage.py v7.15.0, created at 2026-07-08 12:33 +0000
1import os
2from canonicalwebteam.flask_base.env import load_plain_env_variables
5class ConfigurationError(Exception):
6 pass
9# Load the prefixed FLASK_* env vars into env vars without the prefix. We have
10# to do this explicitly here because otherwise the config module is imported
11# by other files before the FlaskBase app gets initialized and does this by
12# itself, meaning that the variables below are not set correctly
13load_plain_env_variables()
15SECRET_KEY = os.getenv("SECRET_KEY")
16LOGIN_URL = os.getenv("LOGIN_URL", "https://login.ubuntu.com")
17BSI_URL = os.getenv("BSI_URL", "https://build.snapcraft.io")
18ENVIRONMENT = os.getenv("ENVIRONMENT", "devel")
19IS_DEVELOPMENT = ENVIRONMENT == "devel"
20COMMIT_ID = os.getenv("COMMIT_ID", "commit_id")
21SENTRY_DSN = os.getenv("SENTRY_DSN", "").strip()
22SENTRY_CONFIG = {"release": COMMIT_ID, "environment": ENVIRONMENT}
23DNS_VERIFICATION_SALT = os.getenv("DNS_VERIFICATION_SALT")
25# Vite integration config values
26VITE_MODE = "development" if IS_DEVELOPMENT else "production"
27VITE_PORT = os.getenv("VITE_PORT", 5173)
28VITE_OUTDIR = os.getenv("VITE_OUTDIR", "static/js/dist/vite")
29# VITE_REACT controls whether React hot module reload scripts are injected when
30# running in dev mode; the setting has no effect in prod mode
31VITE_REACT = True
33if ENVIRONMENT != "devel":
34 SESSION_COOKIE_SAMESITE = "None"
35 SESSION_COOKIE_SECURE = True
37WEBAPP_CONFIG = {"LAYOUT": "_layout.html", "STORE_NAME": "Snap store"}
39WEBAPP_EXTRA_HEADERS = {}
41# Ten years default cache time on static files
42SEND_FILE_MAX_AGE_DEFAULT = 10 * 365 * 24 * 60 * 60
44CONTENT_DIRECTORY = {"PUBLISHER_PAGES": "store/content/publishers/"}
46APP_NAME = "snapcraft"
48# Fallback icon shown when a snap has no icon of its own
49DEFAULT_ICON_URL = (
50 "https://assets.ubuntu.com/v1/be6eb412-snapcraft-missing-icon.svg"
51)
53STATUS_BANNER = os.getenv("STATUS_BANNER", "").strip()
55REPORT_SHEET_URL = os.getenv("REPORT_SHEET_URL", "").strip()
56TURNSTILE_SITE_KEY = os.getenv("TURNSTILE_SITE_KEY", "").strip()
57TURNSTILE_SECRET_KEY = os.getenv("TURNSTILE_SECRET_KEY", "").strip()
58TURNSTILE_VERIFY_URL = os.getenv(
59 "TURNSTILE_VERIFY_URL",
60 "https://challenges.cloudflare.com/turnstile/v0/siteverify",
61).strip()