@appsforgood/next-supabase-kit 0.4.1 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/UPGRADE.md +11 -0
  3. package/USER_GUIDE.html +5 -5
  4. package/USER_GUIDE.md +5 -5
  5. package/agents/app-engineer/agent.md +2 -0
  6. package/dist/index.js +1 -1
  7. package/dist/index.js.map +1 -1
  8. package/examples/next-supabase-installed/.agent-kit/manifest.json +25 -25
  9. package/examples/next-supabase-installed/.antigravity/runtime-skills/nextjs-app-router/SKILL.md +29 -9
  10. package/examples/next-supabase-installed/.antigravity/runtime-skills/owasp-security-review/SKILL.md +31 -9
  11. package/examples/next-supabase-installed/.antigravity/runtime-skills/planning/SKILL.md +11 -5
  12. package/examples/next-supabase-installed/.antigravity/runtime-skills/postgres-migrations/SKILL.md +25 -7
  13. package/examples/next-supabase-installed/.antigravity/runtime-skills/supabase-auth-rls/SKILL.md +41 -9
  14. package/examples/next-supabase-installed/.antigravity/runtime-skills/testing-qa/SKILL.md +3 -3
  15. package/examples/next-supabase-installed/.claude/agents/app-engineer.md +2 -0
  16. package/examples/next-supabase-installed/.codex/agents/app-engineer.toml +2 -0
  17. package/examples/next-supabase-installed/.cursor/agents/app-engineer.md +2 -0
  18. package/examples/next-supabase-installed/.cursor/skills/nextjs-app-router/SKILL.md +29 -9
  19. package/examples/next-supabase-installed/.cursor/skills/owasp-security-review/SKILL.md +31 -9
  20. package/examples/next-supabase-installed/.cursor/skills/planning/SKILL.md +11 -5
  21. package/examples/next-supabase-installed/.cursor/skills/postgres-migrations/SKILL.md +25 -7
  22. package/examples/next-supabase-installed/.cursor/skills/supabase-auth-rls/SKILL.md +41 -9
  23. package/examples/next-supabase-installed/.cursor/skills/testing-qa/SKILL.md +3 -3
  24. package/examples/next-supabase-installed/USER_GUIDE.html +5 -5
  25. package/examples/next-supabase-installed/USER_GUIDE.md +5 -5
  26. package/examples/next-supabase-installed/skills/nextjs-app-router/SKILL.md +29 -9
  27. package/examples/next-supabase-installed/skills/owasp-security-review/SKILL.md +31 -9
  28. package/examples/next-supabase-installed/skills/planning/SKILL.md +11 -5
  29. package/examples/next-supabase-installed/skills/postgres-migrations/SKILL.md +25 -7
  30. package/examples/next-supabase-installed/skills/supabase-auth-rls/SKILL.md +41 -9
  31. package/examples/next-supabase-installed/skills/testing-qa/SKILL.md +3 -3
  32. package/package.json +1 -1
  33. package/research/agent-skill-gap-report.md +4 -0
  34. package/skills/nextjs-app-router/SKILL.md +29 -9
  35. package/skills/owasp-security-review/SKILL.md +31 -9
  36. package/skills/planning/SKILL.md +11 -5
  37. package/skills/postgres-migrations/SKILL.md +25 -7
  38. package/skills/supabase-auth-rls/SKILL.md +41 -9
  39. package/skills/testing-qa/SKILL.md +3 -3
@@ -1,23 +1,55 @@
1
1
  ---
2
2
  name: supabase-auth-rls
3
- description: Use for Supabase Auth, SSR clients, middleware, sessions, Row Level Security, Storage policies, and service-role usage.
3
+ description: Use for Supabase Auth, SSR clients, session refresh, RLS, Storage policies, and keeping the service role server-only. UI checks are not authorization.
4
4
  ---
5
5
 
6
6
  # Supabase Auth And RLS
7
7
 
8
+ Scan 2026-09-09 (structure only, no bodies copied): Supabase SSR Auth, RLS, and Storage policy docs. Do not replace this pack with a non-Supabase auth vendor.
9
+
8
10
  ## Use when
9
11
 
10
- Supabase Auth, SSR clients, middleware, sessions, tables, policies, Storage, or service-role operations.
12
+ Supabase Auth, cookie/SSR clients, `proxy.ts` / middleware session refresh, RLS, Storage, service-role usage, or any table that stores user or tenant data.
13
+
14
+ ## Do
15
+
16
+ 1. Name the table or bucket and who may read or write a row.
17
+ 2. Use the **anon/user SSR client** in user requests. Use the **service role** only in a server-only module that never imports into Client Components.
18
+ 3. Enable RLS and write policies in the **same change** as the table (`postgres-migrations`).
19
+ 4. Prove a negative: another user (or anon) cannot read or write the row.
20
+
21
+ ## Clients
22
+
23
+ | Client | Where | Key |
24
+ | --- | --- | --- |
25
+ | Browser / `'use client'` | Components that must talk to Supabase in the browser | `NEXT_PUBLIC_SUPABASE_ANON_KEY` only |
26
+ | SSR / Server Components / Actions / Route Handlers | Cookie session, `createServerClient` | Anon key + cookies |
27
+ | Service role | Server-only jobs, webhooks, migrations | `SUPABASE_SERVICE_ROLE_KEY` — never `NEXT_PUBLIC_` |
28
+
29
+ Auth decisions use `getUser()` (or equivalent server verification), not a client-trusted `getSession()` JWT.
30
+
31
+ If the app intercepts requests, refresh the session there (`proxy.ts` or existing `middleware.ts`) so Server Components see a current user.
32
+
33
+ ## RLS And Storage
34
+
35
+ - `ENABLE ROW LEVEL SECURITY` on every user-owned, tenant-owned, or privileged table.
36
+ - Policies name ownership (`auth.uid()`) and tenant boundaries. An “authenticated” role is not ownership.
37
+ - Storage buckets have explicit policies. A private bucket with a public URL is a finding.
38
+ - Privileged bypass (service role, `security definer`) is listed, server-only, and as narrow as the job.
11
39
 
12
40
  ## Checks
13
41
 
14
- - RLS is enabled on user-owned and tenant-owned tables.
15
- - Policies enforce ownership and tenant boundaries.
16
- - Service-role keys stay server-only.
17
- - Auth middleware refreshes sessions safely.
18
- - Storage buckets have explicit policies.
19
- - IDOR is considered and tested at the policy boundary.
42
+ - IDOR is tested at the **policy** (and server) boundary: object IDs in the URL or body cannot reach another user’s row.
43
+ - Login, logout, expired session, and denied are exercised when those states exist. User-visible ones need `browser-qa`.
44
+ - `.env.example` documents public anon URL/key placeholders only. Service role stays unnamed in client files.
45
+
46
+ ## Reject
47
+
48
+ - “The button is hidden, so they cannot hit the API.”
49
+ - RLS deferred to a follow-up PR while the table is already queryable.
50
+ - Service role in `NEXT_PUBLIC_*`, in a Client Component, or in a file imported by one.
51
+ - Trusting `user_id` from the request body instead of `auth.uid()`.
20
52
 
21
53
  ## Done when
22
54
 
23
- A table that stores user data cannot be read or written across users without a failing policy. UI checks are not treated as authorization.
55
+ A second user (or anon) cannot read or write the protected row. UI checks are not treated as authorization. Hand user-visible auth states to QA with `browser-qa`.
@@ -14,14 +14,14 @@ Adding or reviewing tests, smoke checks, or regression coverage.
14
14
  - Core logic has unit tests.
15
15
  - Preserved behavior has regression tests.
16
16
  - Critical flows have Playwright or equivalent smoke tests.
17
- - Auth and mutation paths are prioritized.
17
+ - Auth, RLS, and mutation paths are prioritized (other-user / anon cannot pass).
18
18
  - Network failure, empty, and error behavior is covered.
19
19
  - Gaps are named when infrastructure is missing.
20
20
 
21
21
  ## Visual proof
22
22
 
23
- User-visible screens also require `browser-qa`. This skill does not replace screenshots.
23
+ User-visible screens also require `browser-qa`. This skill does not replace screenshots. Passing `toBeVisible` is not image review.
24
24
 
25
25
  ## Done when
26
26
 
27
- Commands run, results, and residual gaps are listed.
27
+ Commands run, results, and residual gaps are listed. RLS/auth tests fail closed when another user can read the row.