End-user database access
Expose user-specific rows through the Data API.
Neon · Const
Neon authorizes end users through the Data API with JWTs. The token determines the PostgreSQL role used for the query, while GRANT permissions and Row-Level Security control access.
Neon authorizes end users through the Data API with a JWT from a trusted issuer. The API validates the token, chooses a PostgreSQL role from it, and executes the query under that role, where GRANT permissions and Row-Level Security determine access.
Authorization: Bearer <your_jwt_token>| Name | Type | Description |
|---|---|---|
Authorization header | Bearer JWT | JWT supplied in the HTTP Authorization: Bearer <token> header. |
A Data API query result authorized and executed under the PostgreSQL role selected from the JWT.
const { data } = await sql`select auth.user_id();`;Run a Data API query after Neon has authorized the request's JWT and made its identity available to PostgreSQL.
Expose user-specific rows through the Data API.
Apply PostgreSQL Row-Level Security based on the authenticated identity.
Use an external identity provider with Neon.
Neon uses a JWT to authorize end users through the Data API. The API selects a PostgreSQL role from the token, then PostgreSQL permissions and RLS policies control the query.
Follow-up: What role is used for a valid ordinary user token? The API switches to the authenticated role unless a custom role is selected from the JWT role claim.
The JWT identifies the user through its sub claim. RLS policies can use that identity to restrict rows, so the claim must be present when policies depend on it.
Follow-up: What happens without a valid signed-in user token? The request is treated as anonymous and uses the anonymous role, unless the configured authorization setup provides another role.
The request carries the token in the HTTP Authorization header using the Bearer scheme. Neon validates the token from a trusted issuer before selecting the database role.
Follow-up: How can an application support a provider other than Neon Auth? Configure that provider's JWKS URL so the Data API can validate its JWTs.
Data APINeon AuthRow-Level Security (RLS)authenticated roleanonymous roleauth.user_id()