Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Neon 9 min read Deep dive mediumAdept

WTF Are JWTs?

JSON Web Tokens are compact, signed, self-contained tokens made of three base64url segments (header, payload of registered and custom claims, and an HMAC or RSA signature). They replaced database-backed sessions for stateless, cross-service auth. A worked Node.js example builds an HS256 token by hand, and JWKS endpoints let services fetch an auth provider's public keys by kid to verify tokens and support key rotation. In Neon RLS, verified claims such as tenant_id drive Postgres row-level security policies. JWTs are signed but not encrypted, so sensitive data should stay out of the payload or use encrypted JWTs.

Related posts

  • Introducing JWT Signing Keys

    Supabase mediumAdept

    Supabase Auth now supports asymmetric JWT signing keys (RSA or elliptic curve), letting apps verify tokens locally using public keys published at a JWKS endpoint instead of calling the Auth server or sharing a forgeable secret. Migration is a reversible, zero-downtime sequence: import the legacy secret, generate a standby key pair, rotate to sign with the new private key, then revoke the old secret. A new getClaims() client function verifies tokens via the Web Crypto API with cached public keys, and any JWT library such as jose works too. New publishable and secret API keys replace the JWT-based anon and service_role keys, with asymmetric keys becoming the default for new projects from October 2025 and legacy keys phased out by late 2026.

  • JSON Web Keys (JWK): Rotating Cryptographic Keys at Zalando

    Zalando Engineering mediumAdept

    Zalando's OIDC identity provider rotates its JWT signing keys automatically on a schedule, using a phased process so clients are never disrupted. A new key pair is generated and its public key is published on the JWK endpoint, with a grace period so clients can refresh cached key sets. The new key is then promoted to active signer, while the retired key stays published until every token it signed has expired. Removal time is computed as retirement time plus maximum token lifetime plus a safety margin, using the key ID embedded in each JWT.

  • Introducing Neon RLS: Simplifying Row-Level Security For Postgres

    Neon mediumAdept

    Neon RLS lets Postgres row-level security policies authenticate requests with JWTs from any auth provider that exposes a JWKS URL. The Neon Proxy verifies the token and exposes its claims through auth.user_id() and auth.session() from the open-source pg_session_jwt extension, for use in RLS policies and WHERE clauses. A Drizzle ORM integration adds pgPolicy and crudPolicy helpers so policies are declared alongside the schema. Neon recommends RLS for core authorization rules such as multi-tenant isolation, keeping intricate access logic in backend code, and says backend-less client apps are only suitable for simple projects.

  • Introducing JWT authentication in ClickHouse Cloud

    ClickHouse mediumAdept

    ClickHouse Cloud (26.4+) can authenticate clients with short-lived JWTs from any OpenID Connect provider such as Okta or Microsoft Entra, replacing database passwords. ClickHouse verifies the token signature against the provider's JWKS, then creates an in-memory ephemeral user named JWT::<subject>::<claims_hash> carrying the roles from the token, and removes it after expiry, so no CREATE/DROP USER provisioning is needed. Quotas, settings profiles and row policies attach to a stable UUID derived from issuer, subject and audience, and definer views get a persistent non-login shadow user so they survive token expiry. Client libraries for JS, Python, Go and Java accept bearer tokens with refresh hooks, and custom providers require the Enterprise plan.

  • How to Set Up Row-Level Security in Postgres Using AWS Cognito

    Neon mediumAdept

    Postgres row-level security can be driven by AWS Cognito JWTs: a Cognito User Pool issues tokens, and Neon Authorize validates them and maps claims like `sub` into Postgres session variables. A `notes` table gets an RLS policy comparing `user_id` to `current_setting('jwt.claims.sub')`, so each user sees only their own rows. The demo app uses Express.js, HTMX and the Neon serverless driver, with step-by-step setup for Cognito, the database schema, environment variables and policy verification. Neon has since folded this functionality into the Neon Data API.

The quest for software engineering knowledge.

Look:
Layout: