Scaffold FastAPI + MySQL + Keycloak service with devcontainer
Sets up the project skeleton: - FastAPI app factory with lifespan, request-id middleware, and RFC 9457 problem+json error handlers - Async SQLAlchemy 2.0 over MySQL (asyncmy), with a constraint naming convention in place before the first migration and async Alembic - Keycloak as a pure resource server: OIDC discovery, cached JWKS with rotation-aware refresh, and require_roles dependencies - Devcontainer running MySQL 8.4 and Keycloak 26.7 as compose siblings, with the realm (clients, roles, test users) imported on first boot - Test suite covering the endpoints plus the token validator itself, exercised against a locally generated RSA keypair - uv packaging, ruff, mypy --strict, pre-commit, Gitea CI, prod Dockerfile Two Keycloak-in-containers traps are handled explicitly and documented in the README: the issuer/internal-URL split (the browser sees localhost:8080, the API sees keycloak:8080) and the audience mapper that stops Keycloak issuing tokens with aud=account. The devices resource is a placeholder proving the routing -> auth -> ORM -> migration path end to end; replace it with the real domain. Co-Authored-By: Claude Opus 5 <[email protected]>
This commit is contained in:
commit
0526d34e42
52 files changed
+4433
No files matched your search
@@ -0,0 +1,13 @@
|
||||
-- Runs once, on the first boot of an empty mysql-data volume.
|
||||
--
|
||||
-- MYSQL_DATABASE/MYSQL_USER in compose.yaml already create `v2x` and grant the
|
||||
-- app user on it. This adds the separate database the test suite runs against,
|
||||
-- so tests never touch development data.
|
||||
|
||||
CREATE DATABASE IF NOT EXISTS v2x_test
|
||||
CHARACTER SET utf8mb4
|
||||
COLLATE utf8mb4_0900_ai_ci;
|
||||
|
||||
GRANT ALL PRIVILEGES ON v2x_test.* TO 'v2x'@'%';
|
||||
|
||||
FLUSH PRIVILEGES;
|
||||
Reference in new issue
Block a user