Skip to content

Commit 07c2773

Browse files
os-zhuangclaude
andauthored
fix(auth): make the SSO Providers list visible to admins (ADR-0024 / cloud#551) (#2394)
The sys_sso_provider Setup list rendered empty even after an admin registered a provider — member_default's wildcard tenant_isolation RLS denied every row (better-auth writes via its adapter with no tenantId → organization_id never stamped; the platform-admin viewAllRecords bypass is gated to private/non-tenant objects). sys_sso_provider is env-global admin-only identity config, so it now declares tenancy.enabled:false (admin viewAllRecords sees all env providers) + requiredPermissions:['manage_platform_settings'] (object-level gate so members are 403'd; without it tenancy-disabled + member_default '*' allowRead would leak). Verified E2E: admin sees all providers in the list, non-admin → 403. Env-only object (no control-plane risk). Co-authored-by: Jack Zhuang <277994282+os-zhuang@users.noreply.github.com> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 69ae136 commit 07c2773

2 files changed

Lines changed: 29 additions & 0 deletions

File tree

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
'@objectstack/platform-objects': patch
3+
---
4+
5+
Auth: make the SSO Providers list visible to admins (ADR-0024 / cloud#551)
6+
7+
The `sys_sso_provider` Setup list rendered empty even after an admin registered a provider: `member_default`'s wildcard `tenant_isolation` RLS (`organization_id == current_user.organization_id`) denied every row, because better-auth writes these via its adapter with no tenantId context so `organization_id` is never stamped, and the platform-admin `viewAllRecords` superuser bypass is gated to private/non-tenant objects.
8+
9+
`sys_sso_provider` is env-global, admin-only identity config, so it now declares:
10+
- `tenancy: { enabled: false }` — opts out of multi-tenancy (the env IS the tenant; providers are env-wide), letting a platform admin's `viewAllRecords` bypass see every provider.
11+
- `requiredPermissions: ['manage_platform_settings']` — object-level capability gate so ordinary members are denied (without it, tenancy-disabled + `member_default`'s `'*': allowRead` would expose providers to every authenticated user).
12+
13+
Verified E2E: an admin sees all env providers in the Setup → Access Control → SSO Providers list; a non-admin gets 403. (Env-only object — no control-plane cross-tenant impact. The sibling `sys_oauth_application` / `sys_account` nav entries share the same empty-list symptom but span the control plane and need separate per-object analysis.)

packages/platform-objects/src/identity/sys-sso-provider.object.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,22 @@ export const SysSsoProvider = ObjectSchema.create({
3131
icon: 'shield-check',
3232
isSystem: true,
3333
managedBy: 'better-auth',
34+
// ADR-0024 — env-global, ADMIN-ONLY identity config. Two orthogonal controls:
35+
// • `tenancy.enabled: false` — the env IS the tenant; providers are env-wide,
36+
// not org-partitioned. Opting out of multi-tenancy lets a platform admin's
37+
// `viewAllRecords` superuser bypass see every provider (without it, the
38+
// `member_default` wildcard `tenant_isolation` RLS denies every row, since
39+
// better-auth writes via its adapter with no tenantId → `organization_id`
40+
// is never stamped).
41+
// • `requiredPermissions: ['manage_platform_settings']` — object-level
42+
// capability gate (ADR-0066 D3) so ordinary members are denied entirely
43+
// (without it, tenancy-disabled + `member_default`'s `'*': allowRead` would
44+
// leak providers to every authenticated user).
45+
// Together: admins see all env providers; non-admins get 403. better-auth's
46+
// own endpoints already read via a system context. (Env-only object — no
47+
// control-plane cross-tenant risk.)
48+
tenancy: { enabled: false, strategy: 'shared' },
49+
requiredPermissions: ['manage_platform_settings'],
3450
// ADR-0010 §3.7 — managed by better-auth; tenants may not edit schema.
3551
protection: {
3652
lock: 'full',

0 commit comments

Comments
 (0)