Skip to content

Give the bootstrap provisioning key the scopes integrators need - #202

Merged
s3rot0n1n merged 1 commit into
mainfrom
fix/bootstrap-provisioning-key-scopes
Nov 15, 2026
Merged

s3rot0n1n merged 1 commit into
mainfrom
fix/bootstrap-provisioning-key-scopes

Conversation

@clbotdev

Copy link
Copy Markdown
Contributor

Why

The team-provisioning key that bootstrap registers from BOOTSTRAP_TEAM_PROVISIONING_API_KEY had only organization:read, teams:provision and teams:read. An integrator such as CourseLit also needs to manage the teams it creates. Updating a team's quota and sender (PATCH), suspending, resuming and archiving it need teams:manage; re-keying needs teams:keys; reading usage needs usage:read. On installs set up through bootstrap, those calls returned 403.

What changes

  • The provisioning key now also gets teams:manage, teams:keys and usage:read.
  • registerConfiguredOrganizationApiKey takes an opt-in reconcileScopes. Bootstrap passes it, so a key it registered earlier under the same name gets its stored scopes updated on restart, instead of startup failing with configured_organization_api_key_scope_mismatch.
  • Every other case still fails closed: a key with a different name (another role, or one created by hand whose secret ends up in the setting), a different organization, or a revoked or expired key.
  • Docs that list the provisioning key's scopes are updated.

Tests

  • apikey/queries.test.ts: upgrading and narrowing a configured key's scopes; a revoked key isn't reconciled; a scope change without opt-in still fails; a generated key can't be reconciled even under the bootstrap name. 9 pass.
  • bootstrap.test.ts: the new scope list and the opt-in. 6 pass when run with --no-env-file; apps/api/.env breaks two of these tests on main too.
  • bun run typecheck is clean.

The team-provisioning key registered at bootstrap now also has
teams:manage, teams:keys and usage:read, so an integrator can update,
archive and re-key the teams it provisions and read their usage.

Bootstrap reconciles the stored scopes of the key it registered under
the same name, so existing installs pick up the new scopes on restart
instead of failing. Any other scope mismatch still fails closed.
@s3rot0n1n
s3rot0n1n merged commit 6147e34 into main Nov 15, 2026
6 of 7 checks 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.

2 participants