1
0
Fork 0
Commit Graph

13 Commits

Author SHA1 Message Date
Jonny 63866f7f50 feat: add login page with server action and validation 2026-07-04 15:47:54 +02:00
Jonny 7254923885 feat: add Supabase browser and server client helpers
- Add browser client helper (createClient) for client-side components
- Add server client helper (createClient) for server components and route handlers
- Add test for browser client functionality
- Update .gitignore to allow .env.local.example while ignoring .env*.local
- Install @supabase/supabase-js and @supabase/ssr packages

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-04 15:32:05 +02:00
Jonny a8ca6445cb fix: add reproducible render step for kong.yml and 99-roles.sql templates
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>
2026-07-04 15:24:49 +02:00
Jonny e0a3e756d8 feat: add self-hosted Supabase stack via Docker Compose
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>
2026-07-04 12:35:08 +02:00
Jonny 16f8b09606 docs: correct plan for auth schema lockdown and missing grants
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).
2026-07-04 12:00:44 +02:00
Jonny d13994b386 feat: add RLS policies and pgTAP tests for profiles 2026-07-04 11:58:09 +02:00
Jonny 92adebd710 fix: never derive new user role from raw_user_meta_data (privilege escalation)
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.
2026-07-04 11:48:26 +02:00
Jonny 2f2f354402 docs: fix plan to prevent role privilege escalation via user metadata
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.
2026-07-04 11:42:16 +02:00
Jonny a9e67ce04d feat: add profiles table, role enum and auto-create trigger 2026-07-04 11:30:13 +02:00
Jonny 704fb83a58 chore: scaffold Next.js app with Vitest 2026-07-04 10:58:26 +02:00
Jonny 4b83a19552 chore: ignore .worktrees/ directory 2026-07-04 10:52:45 +02:00
Jonny a1e08fb1d0 docs: add implementation plan for foundation (auth & roles)
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.
2026-07-04 10:38:25 +02:00
Jonny 0643bef299 chore: initial commit - requirements and foundation design spec
Sets up Aushilfsfahrer as its own repository with the project
requirements (CLAUDE.md) and the design spec for the foundation
subproject (auth, roles, infra).
2026-07-04 10:27:07 +02:00