UI REST API: accounts, bearer auth, API apps, sessions, OpenAPI docs
CI / lint (push) Successful in 14s
CI / test (push) Successful in 28s
CI / notify (push) Successful in 5s

- flask-smorest API under /api/v1 with a uniform JSON error shape;
  spec at /api/openapi.json, Swagger UI at /api/docs, ReDoc at /api/redoc
- Register/login/logout/me with hashed, expiring bearer tokens,
  documented as an OpenAPI bearer security scheme
- API application and client-session management endpoints
- CORS restricted to the configured UI origin(s)
- Flask no longer serves static files: it is API-only
- Login and registration metrics

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
mattandClaude Opus 5.5 committed 2026-09-25 13:59:59 +01:00
1 parent 9af8a4be8b
commit e026e56ee3
13 files changed
+626 -1

No files matched your search

+24
View File
@@ -25,6 +25,30 @@ class Config:
# server is started by gunicorn.conf.py instead, so this stays off there.
START_METRICS_SERVER = os.environ.get("START_METRICS_SERVER", "0") == "1"
# OpenAPI document and docs (flask-smorest)
API_TITLE = "Scrobbler API"
API_VERSION = "v1"
OPENAPI_VERSION = "3.1.0"
OPENAPI_URL_PREFIX = "/api"
OPENAPI_JSON_PATH = "openapi.json"
OPENAPI_DOCS_ENABLED = os.environ.get("OPENAPI_DOCS_ENABLED", "1") == "1"
OPENAPI_SWAGGER_UI_PATH = "docs" if OPENAPI_DOCS_ENABLED else None
OPENAPI_SWAGGER_UI_URL = os.environ.get(
"OPENAPI_SWAGGER_UI_URL", "https://cdn.jsdelivr.net/npm/swagger-ui-dist@5/"
)
OPENAPI_REDOC_PATH = "redoc" if OPENAPI_DOCS_ENABLED else None
OPENAPI_REDOC_URL = os.environ.get(
"OPENAPI_REDOC_URL", "https://cdn.jsdelivr.net/npm/redoc@2/bundles/redoc.standalone.js"
)
API_SPEC_OPTIONS = {
"info": {
"description": (
"Two APIs: `/2.0/` is Last.fm (Audioscrobbler 2.0) compatible, for players "
"and scrobblers; `/api/v1/` is the JSON API used by the web UI."
)
},
}
# Last.fm behaviour
AUTH_TOKEN_TTL_SECONDS = 60 * 60
UI_TOKEN_TTL_DAYS = 30