Skip to content

feat(auth): expose isPlatformAdmin on the customSession user#1859

Merged
xuyushun441-sys merged 2 commits into
mainfrom
adr-adminvis-framework
Jun 15, 2026
Merged

feat(auth): expose isPlatformAdmin on the customSession user#1859
xuyushun441-sys merged 2 commits into
mainfrom
adr-adminvis-framework

Conversation

@xuyushun441-sys

Copy link
Copy Markdown
Contributor

What

Attach an isPlatformAdmin boolean to the better-auth customSession user payload (both return paths).

Why

The session already derives a coarse admin role for platform admins or active-org admins, but never surfaces the underlying platform-admin signal. Console action visible CEL predicates need to gate platform-admin-only actions (e.g. sys_environment.change_plan, labeled "Change Plan (admin)") — today a regular user sees the button and clicking it 403s. The admin role alone can't distinguish org-admin from platform-admin.

Change

packages/plugins/plugin-auth/src/auth-manager.ts: capture const platformAdmin = await isPlatformAdmin() once, reuse it for the existing promote logic, and add isPlatformAdmin: platformAdmin to both customSession returns. Org-admins who are not platform admins correctly get false.

Real authz stays server-side; this only enables a UX visibility gate downstream (objectui + cloud).

Validation

  • turbo build --filter=@objectstack/plugin-auth green incl. DTS
  • @objectstack/plugin-auth tests: 114/114 pass

🤖 Generated with Claude Code

The session payload already derives an `admin` role when the user is a
platform admin or active-org admin, but it never surfaces the underlying
platform-admin boolean. Console action `visible` CEL predicates need to
distinguish platform-admin-only actions (e.g. sys_environment.change_plan)
from org-admin actions, which a coarse `admin` role cannot do.

Capture the platform-admin check once and attach `isPlatformAdmin` to both
customSession return paths. Org-admins who are not platform admins get
`isPlatformAdmin: false` (correct — those actions are platform-admin-only).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented Jun 15, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
spec Ready Ready Preview, Comment Jun 15, 2026 3:44am

Request Review

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added documentation Improvements or additions to documentation tooling size/s and removed size/xs labels Jun 15, 2026
@xuyushun441-sys xuyushun441-sys merged commit 1b82b64 into main Jun 15, 2026
13 checks passed
@xuyushun441-sys xuyushun441-sys deleted the adr-adminvis-framework branch June 15, 2026 03:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/s tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants