Pinned 2026 toolchains (Go 1.26, Rust 1.98/edition 2024, Python 3.14 + uv, Node 24, Zig 0.16, NixOS 26.05), postgres 18 / mongo 8, lockfiles built from, non-root runtimes, .dockerignore, per-project LICENSE, READMEs with the git.devai.io clone line, checkout@v7 CI. Security fixes in the legacy Rust APIs (any-password login, self-assigned admin, hard-coded JWT secret), JWT alg/exp/sub enforcement across the blog series, safe markdown links in the frontends, and many smaller bugs — every project was built, run and exercised end to end. Adds scripts/publish.sh + a CI publish job that splits every folder into its own repo at git.devai.io/templates/<folder>. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01128fhuZbgivaSJvtMf4s1G
1.4 KiB
1.4 KiB
Auth via Clerk
Replaces the built-in email/password auth with Clerk.
Clerk owns sign-up, sign-in and sessions; the API only verifies the session
JWT it receives against your instance's JWKS (RS256 signature, issuer,
expiry, azp). One file, no Clerk SDK.
Install
- Add the RS256 backend:
uv add "pyjwt[crypto]" - Copy
clerk_auth.pytoapp/clerk_auth.py - In
app/posts.py, change one import:from .clerk_auth import current_user_id - Set
CLERK_ISSUERto your Frontend API URL from the Clerk dashboard, e.g.https://your-app.clerk.accounts.dev, andCLERK_AUTHORIZED_PARTIESto the origins allowed to mint tokens for this API (comma-separated, checked against theazpclaim; leave it unset to skip the check), e.g.https://your-site.com,http://localhost:5173
Delete / adjust
app/auth.pyand its router registration inapp/main.py— Clerk replaces/auth/registerand/auth/login.- The
userscollection and its email index inapp/db.py— Clerk stores your users. posts.author_idnow holds a Clerk user id (a string likeuser_2f…) instead of an ObjectId string. It was already stored as a string, so nothing to migrate — only the id format changes.AUTH_SECRETis unused.
Clients get a token from Clerk's SDK (getToken()) and send it as
Authorization: Bearer <token> — the write endpoints work unchanged.