docs(data-api): explain JWT role claim and anonymous fallback for custom providers - #5555
Draft
bgrenon wants to merge 1 commit into
Draft
docs(data-api): explain JWT role claim and anonymous fallback for custom providers#5555bgrenon wants to merge 1 commit into
bgrenon wants to merge 1 commit into
Conversation
…tom providers The Data API takes the database role from the JWT `role` claim; a token with no role claim falls back to the `anonymous` role, which has no table grants by default and returns 42501. Custom (JWKS) providers don't stamp `role: authenticated` unless configured to, so their tokens hit 42501 even when `authenticated` is granted. Correct the misleading "valid token -> authenticated" wording in access-control, add a "Required JWT claims" section to custom-authentication-providers, and add this cause to the 42501 troubleshooting entry. Fixes LKB-16518 Co-authored-by: Isaac
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Doc-only fixes from the docs-drift feedback audit: 3 Data API pages corrected so custom (JWKS) auth providers understand how the database role is chosen. Not auto-merged — awaiting your review.
Why
A custom-JWKS token can be accepted (valid signature) yet still get
42501 permission denied for table X, even though the table is granted toauthenticatedandSET ROLE authenticatedworks in the SQL Editor. The cause: the Data API takes the database role from the JWTroleclaim. Neon Auth stampsrole: authenticated, but a custom provider does not unless you configure it to. With no matchingroleclaim, the request runs as the fallbackanonymousrole, which has schemaUSAGEbut no table grants, so it returns 42501. The docs didn't explain this, andaccess-control.mdimplied any valid token becomesauthenticated.Changes
1.
access-control.md— the role always comes from theroleclaim (was: "valid token")authenticatedrole.""role": "authenticated". ... A valid signature on its own does not grant theauthenticatedrole; the token must actually carry"role": "authenticated"."## API Rolesintro and the "Custom roles" section around the general rule (the role is whatever the claim names;anonymousis the fallback), and fixes the page summary.role: authenticatedreturns200with rows; the same request with noroleclaim returns403/42501. The role is selected from the claim, not from token validity.2.
custom-authentication-providers.md— new "Required JWT claims" sectionExplains that the token must carry a
roleclaim naming a granted role, that using the defaultauthenticatedrole requires the provider to issue"role": "authenticated", and that a missing role claim falls back toanonymous(no table access) and returns 42501.3.
troubleshooting.md— new cause under "Permission denied for table" (42501)Adds the custom-provider / absent-role-claim case and the fix (issue a
roleclaim naming a granted role, or point the Data API's JWT role claim key at your provider's claim).Files
content/docs/data-api/access-control.mdroleclaim, not from token validity; fix summary + 3 role subsectionscontent/docs/data-api/custom-authentication-providers.mdcontent/docs/data-api/troubleshooting.mdHow to verify
Text-only; no build or runtime behavior is affected. To check the behavior the docs now describe, enable the Data API with a custom (external JWKS) provider and grant
SELECTon a table toauthenticated, then call the Data API:"role": "authenticated"returns200with rows.roleclaim returns403with{"code":"42501","message":"permission denied for table ..."}— it ran asanonymous.roleclaim names a role that doesn't exist returns400with{"code":"22023","message":"role \"...\" does not exist"}.Verified against live Neon: the three calls above returned 200 (rows), 403/42501, and 400/22023 respectively, with the Data API configured for a custom JWKS provider and default grants to
authenticated.Fixes LKB-16518
Source: neon-docs-drift feedback feed (#lakebase-feed-user-feedback)