Commit ade3980
committed
feat(auth): add Supabase org authz profile
Introduce an opt-in supabase_org deployment profile that models an
organization as the Hindsight tenant. The dataplane now has built-in
SupabaseOrgTenantExtension and SupabaseAuthorizationExtension classes
sharing a policy resolver for Supabase JWTs and Hindsight scoped API
keys. The resolver maps callers to organization schemas, member roles,
bank scopes, operation scopes, and tenant config without changing the
existing default, API key, or user-level Supabase tenant modes.
Wire profile validation into API startup, uvicorn import startup, and
worker startup so partial supabase_org deployments fail fast. Expose
authz profile details through version features so the control plane can
detect mismatched dataplane configuration instead of silently entering a
half-working state.
Add the control-plane supabase_org auth provider with login, signup,
logout, selected-organization cookies, organization switching, team
management, manual invite links, and Hindsight scoped API key
management. Existing API wrappers now create request-scoped dataplane
clients, forwarding the user's Supabase JWT and X-Hindsight-Org-Id in
supabase_org mode while preserving fixed dataplane API key behavior for
access_key and disabled modes.
Add Supabase local-stack config and migrations for organizations,
memberships, invites, API keys, and bank scopes. These authorization
metadata tables live in public for PostgREST access but enable RLS and
define no anon/authenticated policies, so browser clients must go
through the control-plane wrapper APIs while server-side code uses the
service role key.
Cover the implementation with resolver and extension unit tests,
control-plane auth/store/header-forwarding tests, a route scan that
prevents app API routes from importing global dataplane clients, and a
Supabase CLI integration test that exercises real Auth, PostgREST,
RLS, JWT resolution, and scoped API key resolution. The integration CI
job now installs a pinned Supabase CLI and also runs when control-plane
changes touch the local Supabase project.
Document the implemented V1 boundaries in code and tests: manual
invites only, no password recovery UI, no organization schema deletion
flow, no child API keys, no memory-level ACLs, and no cross-tenant
sharing.1 parent 44972d3 commit ade3980
114 files changed
Lines changed: 4497 additions & 198 deletions
File tree
- .github/workflows
- hindsight-api-slim
- hindsight_api
- api
- engine
- extensions
- builtin
- worker
- tests
- hindsight-clients
- go
- api
- python/hindsight_client_api/models
- typescript/generated
- hindsight-control-plane
- src
- app
- [locale]
- login
- settings
- api
- api-keys
- [id]
- auth
- invites/[token]/accept
- login
- logout
- select-org
- banks
- [bankId]
- audit-logs
- stats
- config
- consolidate
- consolidation-recover
- directives
- [directiveId]
- export
- health/llm
- import
- llm-requests
- stats
- mental-models
- [mentalModelId]
- clear
- history
- refresh
- observations
- [modelId]
- scopes
- operations/[operationId]
- tags
- webhooks
- [webhookId]
- deliveries
- chunks/[chunkId]
- documents
- [documentId]
- chunks
- reprocess
- transfer
- entities
- [entityId]
- regenerate
- graph
- extract
- files/retain
- graph
- health
- list
- memories
- [memoryId]
- history
- retain_async
- retain
- me
- operations/[agentId]
- organizations
- [id]
- profile/[bankId]
- recall
- reflect
- stats/[agentId]
- memories-timeseries
- team
- invites
- [id]
- accept
- members/[userId]
- version
- components
- lib
- auth
- supabase-org
- messages
- supabase
- migrations
- tests/lib
- auth
- supabase-org
- hindsight-docs/static
- hindsight-integration-tests
- tests
- skills/hindsight-docs/references
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2877 | 2877 | | |
2878 | 2878 | | |
2879 | 2879 | | |
| 2880 | + | |
| 2881 | + | |
| 2882 | + | |
| 2883 | + | |
| 2884 | + | |
| 2885 | + | |
| 2886 | + | |
| 2887 | + | |
| 2888 | + | |
| 2889 | + | |
| 2890 | + | |
| 2891 | + | |
| 2892 | + | |
| 2893 | + | |
| 2894 | + | |
| 2895 | + | |
| 2896 | + | |
| 2897 | + | |
| 2898 | + | |
| 2899 | + | |
| 2900 | + | |
| 2901 | + | |
| 2902 | + | |
| 2903 | + | |
| 2904 | + | |
| 2905 | + | |
| 2906 | + | |
| 2907 | + | |
| 2908 | + | |
| 2909 | + | |
| 2910 | + | |
| 2911 | + | |
| 2912 | + | |
| 2913 | + | |
| 2914 | + | |
| 2915 | + | |
| 2916 | + | |
| 2917 | + | |
| 2918 | + | |
| 2919 | + | |
| 2920 | + | |
| 2921 | + | |
| 2922 | + | |
| 2923 | + | |
| 2924 | + | |
| 2925 | + | |
| 2926 | + | |
| 2927 | + | |
| 2928 | + | |
2880 | 2929 | | |
2881 | 2930 | | |
2882 | 2931 | | |
| |||
4701 | 4750 | | |
4702 | 4751 | | |
4703 | 4752 | | |
| 4753 | + | |
4704 | 4754 | | |
4705 | 4755 | | |
4706 | 4756 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
| 66 | + | |
| 67 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2742 | 2742 | | |
2743 | 2743 | | |
2744 | 2744 | | |
| 2745 | + | |
| 2746 | + | |
| 2747 | + | |
| 2748 | + | |
| 2749 | + | |
| 2750 | + | |
| 2751 | + | |
| 2752 | + | |
| 2753 | + | |
| 2754 | + | |
| 2755 | + | |
| 2756 | + | |
| 2757 | + | |
2745 | 2758 | | |
2746 | 2759 | | |
2747 | 2760 | | |
| |||
3040 | 3053 | | |
3041 | 3054 | | |
3042 | 3055 | | |
| 3056 | + | |
| 3057 | + | |
| 3058 | + | |
| 3059 | + | |
| 3060 | + | |
| 3061 | + | |
| 3062 | + | |
| 3063 | + | |
| 3064 | + | |
| 3065 | + | |
| 3066 | + | |
| 3067 | + | |
| 3068 | + | |
| 3069 | + | |
3043 | 3070 | | |
3044 | 3071 | | |
3045 | 3072 | | |
| |||
3078 | 3105 | | |
3079 | 3106 | | |
3080 | 3107 | | |
3081 | | - | |
3082 | | - | |
3083 | | - | |
3084 | | - | |
3085 | | - | |
3086 | | - | |
3087 | 3108 | | |
3088 | 3109 | | |
3089 | 3110 | | |
| |||
3107 | 3128 | | |
3108 | 3129 | | |
3109 | 3130 | | |
| 3131 | + | |
| 3132 | + | |
| 3133 | + | |
| 3134 | + | |
3110 | 3135 | | |
3111 | 3136 | | |
3112 | 3137 | | |
| |||
3292 | 3317 | | |
3293 | 3318 | | |
3294 | 3319 | | |
3295 | | - | |
| 3320 | + | |
| 3321 | + | |
| 3322 | + | |
| 3323 | + | |
3296 | 3324 | | |
3297 | 3325 | | |
3298 | 3326 | | |
| |||
3308 | 3336 | | |
3309 | 3337 | | |
3310 | 3338 | | |
3311 | | - | |
| 3339 | + | |
| 3340 | + | |
| 3341 | + | |
| 3342 | + | |
3312 | 3343 | | |
3313 | 3344 | | |
3314 | 3345 | | |
| |||
3421 | 3452 | | |
3422 | 3453 | | |
3423 | 3454 | | |
| 3455 | + | |
3424 | 3456 | | |
3425 | 3457 | | |
| 3458 | + | |
| 3459 | + | |
| 3460 | + | |
| 3461 | + | |
3426 | 3462 | | |
3427 | 3463 | | |
3428 | 3464 | | |
| 3465 | + | |
| 3466 | + | |
| 3467 | + | |
| 3468 | + | |
| 3469 | + | |
| 3470 | + | |
| 3471 | + | |
3429 | 3472 | | |
3430 | 3473 | | |
3431 | 3474 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1143 | 1143 | | |
1144 | 1144 | | |
1145 | 1145 | | |
| 1146 | + | |
| 1147 | + | |
| 1148 | + | |
1146 | 1149 | | |
1147 | 1150 | | |
1148 | 1151 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
| 23 | + | |
22 | 24 | | |
23 | 25 | | |
24 | 26 | | |
| |||
111 | 113 | | |
112 | 114 | | |
113 | 115 | | |
| 116 | + | |
| 117 | + | |
114 | 118 | | |
115 | 119 | | |
116 | 120 | | |
| |||
Lines changed: 72 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
10 | 12 | | |
11 | 13 | | |
12 | 14 | | |
13 | 15 | | |
14 | 16 | | |
15 | 17 | | |
16 | 18 | | |
| 19 | + | |
17 | 20 | | |
18 | 21 | | |
19 | 22 | | |
20 | 23 | | |
21 | 24 | | |
22 | 25 | | |
| 26 | + | |
| 27 | + | |
23 | 28 | | |
24 | 29 | | |
0 commit comments