Skip to content

Auth0: roles from RBAC permissions on a CodeRunner API - #33

Merged
mathewdunne merged 3 commits into
mainfrom
auth0-rbac-permissions
Nov 12, 2026
Merged

mathewdunne merged 3 commits into
mainfrom
auth0-rbac-permissions

Conversation

@mathewdunne

@mathewdunne mathewdunne commented Nov 12, 2026 •

Copy link
Copy Markdown
Owner

Closes #32.

What

Auth0 sign-ins now get their CodeRunner role from RBAC permissions in an access token for a CodeRunner API, instead of a custom roles claim in the ID token. An ID-token roles claim carries the user's tenant-wide roles, so an admin role meant for another app in the same tenant would also make that user a CodeRunner admin. Permissions are scoped to one API (audience), which keeps each app's access separate.

  • The sign-in request includes audience=AUTH0_AUDIENCE. A custom getUserInfo reads identity and email_verified from the ID token and permissions from the access token. A permissions claim in the ID token is ignored.
  • AUTH0_USER_PERMISSION / AUTH0_ADMIN_PERMISSION default to coderunner:user / coderunner:admin.
  • Auth0 sign-in is enabled only when AUTH0_AUDIENCE is set along with the domain and client credentials. If those three are set without an audience, the server logs a warning and hides the button.
  • Unchanged from decision 044: the CODERUNNER_ADMIN_EMAIL override (verified emails only), denying users in mapProfileToUser before any account is created, and re-reading access at every sign-in.

Breaking config change

AUTH0_ROLES_CLAIM, AUTH0_USER_ROLE_NAME, and AUTH0_ADMIN_ROLE_NAME are removed. To migrate, the tenant needs:

  1. An Auth0 API (its identifier becomes AUTH0_AUDIENCE).
  2. Enable RBAC and Add Permissions in the Access Token turned on for that API.
  3. The two permissions defined on the API and assigned to users through roles.

The old Post-Login Action can then be deleted. On Google Cloud, there's a new coderunner-auth0-audience secret: re-apply Terraform to update the VM's startup script, then add the secret.

Setup steps: docs/deploying/oauth-credentials.md#set-up-auth0. Decision log: docs/decisions/048-auth0-rbac-permissions.md.

Testing

  • auth0.test.ts: the stubbed Auth0 issues a JWT access token with permissions. The full sign-in tests now run against it. New tests check that the sign-in request includes the audience, and that sign-in is denied for ID-token-only permissions, unrelated permissions, and an opaque (no-audience) access token.
  • auth.test.ts: the Auth0 button is hidden when there's no audience.
  • bun run typecheck and bun run check pass.
  • bun run test and bun run e2e (80 tests) pass when run against the bundled lesson catalog.
  • Not tried against a real Auth0 tenant.

Also: Playwright 1.65

ubuntu-latest now resolves to Ubuntu 26.04, and Playwright 1.60 refuses to install Chromium there, so CI was failing on main before any tests ran. Playwright 1.65 supports Ubuntu 26.04.

🤖 Generated with Claude Code

mathewdunne and others added 3 commits November 12, 2026 18:31
Request an access token for AUTH0_AUDIENCE and map its `permissions`
claim (AUTH0_USER_PERMISSION / AUTH0_ADMIN_PERMISSION, defaults
coderunner:user / coderunner:admin) to the CodeRunner role, instead of a
tenant-wide roles claim in the ID token. Permissions are scoped to the one
API, so another app's roles in the same tenant no longer leak in.

Auth0 now needs AUTH0_AUDIENCE to be enabled; AUTH0_ROLES_CLAIM and the
role-name vars are removed. GCE gets a coderunner-auth0-audience secret.
Decision 048.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ubuntu-latest now resolves to Ubuntu 26.04, and Playwright 1.60 refuses
to install Chromium there ("does not support chromium on
ubuntu26.04-x64"), failing CI and release before tests run. 1.65 knows
the platform.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mathewdunne
mathewdunne merged commit eb5e0ee into main Nov 12, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Auth0 Update

1 participant