Per-user API keys: apiKey on BoolUser + auth.rotateApiKey() - #5
Merged
Merged
Conversation
The gateway's /users/me now lazily mints and returns a personal api_key for the signed-in end user (Base44 convention): external callers send it as the `api_key` header and act exactly as that user, same RLS scoping as in the app. SDK side is thin because getUser() passes the server user object through: add the `apiKey?: string` field to BoolUser (typed access to (await auth.getUser()).data.user.apiKey) and an auth.rotateApiKey() helper that POSTs /users/api-key/rotate (old key dies immediately). Pairs with the bool-side gateway change (api_key header → sub → RLS). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
max-bader
marked this pull request as ready for review
July 16, 2026 19:05
This was referenced Jul 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The gateway's
/users/menow lazily mints + returns a personalapi_keyfor the signed-in end user (Base44 convention): external callers send it as theapi_keyheader and act exactly as that user — same per-user RLS scoping as in the app.SDK side is deliberately thin (
getUser()passes the server user object through):BoolUser.apiKey?: string— typed access to the key.auth.rotateApiKey()— POSTs/users/api-key/rotate; the old key stops working immediately. Surfaces the 503 (keys not configured on the deployment) as an error.Tests: 3 new (passthrough, rotate happy path, 503 handling) — 55/55 green, build clean.
Pairs with the bool-side gateway change (accepts
api_key→ stampssub→ existing RLS). Publish as0.2.0-next.7once that lands.🤖 Generated with Claude Code