generate-secrets.js only printed the four secret env vars; nothing rendered
volumes/db/init/99-roles.sql or volumes/api/kong.yml from their committed
.template files, so a fresh clone following the brief's own setup steps
would hit the auth/rest/storage crash-loops and Kong 401s already
diagnosed during the original task.
Add scripts/render-templates.js, which reads .env and writes both rendered
files with the real secrets substituted in. Document the full sequence
(generate secrets -> fill .env -> render templates -> docker compose up)
in the header comments of generate-secrets.js and .env.example.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Produktions-Stack (db, auth, rest, storage, meta, studio, kong) getrennt
vom lokalen CLI-Dev-Stack. Migrationen aus Task 2/3 wurden erfolgreich
angewendet und ein erster Admin-Nutzer angelegt.
Abweichungen vom urspruenglichen Plan (alle beim Testen des laufenden
Stacks gefunden und verifiziert):
- generate-secrets.js: POSTGRES_PASSWORD nutzt base64url statt base64,
da "/" in base64-Passwoertern die Postgres-Connection-URI-Parser von
gotrue/storage-api bricht.
- volumes/db/init/99-roles.sql(.template): das supabase/postgres-Image
setzt POSTGRES_PASSWORD nur fuer die Rolle supabase_admin automatisch;
authenticator/supabase_auth_admin/supabase_storage_admin blieben ohne
Passwort. Zusaetzliches Init-Skript setzt sie explizit.
- volumes/api/kong.yml(.template): Kong 3.9.1 substituiert KEINE
Umgebungsvariablen ($ANON_KEY/$SERVICE_ROLE_KEY) im deklarativen
Config-Format (_transform ist ein Config-Migrations-Flag, kein
Env-Templating) - alle echten Keys wurden mit 401 abgelehnt. Die
Kong-Config wird jetzt lokal aus dem Template mit echten Werten
gerendert (gitignored), analog zu roles.sql.
- storage-Healthcheck: "localhost" statt "127.0.0.1" loeste im Container
zuerst zu ::1 auf, worauf storage-api nicht lauscht.
- studio: HOSTNAME=0.0.0.0 gesetzt, da Docker HOSTNAME sonst auf die
Container-ID setzt und das Next.js-Standalone-Image daran bindet statt
an alle Interfaces (bricht den eingebauten Image-Healthcheck).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Self-hosted Supabase now revokes CREATE on the auth schema from the
migration role, so the RLS helper lives in public.user_role() instead
of auth.user_role(). Also documents the authenticated grants that
Task 2's schema was missing (RLS alone doesn't grant access).
Fixes a CRITICAL finding from automated security review of a9e67ce: the
handle_new_user() trigger read the role from
new.raw_user_meta_data ->> 'role', which is attacker-controllable in
certain GoTrue flows (OAuth, invite links). A user could set
role: admin in their own signup metadata and self-escalate.
Every new user now always gets role = 'readonly' on creation; an admin
must explicitly promote via SQL/Table Editor afterwards (enforced later
by the "Admins aktualisieren alle Profile" RLS policy in Task 3).
Edited the already-applied migration file directly rather than adding a
new one, since this project has no deployment/production data yet.
Verified: inserting a user with raw_user_meta_data = {"role": "admin"}
still results in role = readonly in public.profiles.
Automated security review flagged that reading `role` from
raw_user_meta_data in the profiles trigger lets a user set their own
role at account-creation time in some GoTrue flows (OAuth, invites).
New users now always start as readonly; admins promote them
explicitly afterwards via SQL/table editor.
Nine-task plan covering Next.js scaffold, Supabase schema/RLS/pgTAP,
the self-hosted Docker Compose stack, and the login/middleware/
dashboard flow that later subprojects build on.
Sets up Aushilfsfahrer as its own repository with the project
requirements (CLAUDE.md) and the design spec for the foundation
subproject (auth, roles, infra).