Web App Developer Guides
Drop-in middleware for verifying Twingate Identity Firewall JWTs in your web app.
These guides provide drop-in middleware for verifying Twingate Identity Firewall JWTs in common web frameworks. Each guide follows the same pattern: verify the ES256-signed JWT from the Authorization header, extract the user’s identity, and make it available to your application code. For architecture details and the full JWT reference, see the Identity Firewall for Web Apps overview.
Guides
Express.js
Node.js middleware using the jose library. Attaches the verified identity to req.twingateIdentity.
Django
Python middleware using PyJWT. Attaches the verified identity to request.twingate_identity.
Next.js
Edge Middleware for the Next.js App Router using jose. A thin middleware gates the routes you choose, and a reusable helper verifies the JWT to read the authenticated identity in route handlers and Server Components.
Next.js + Auth.js
Combines Twingate Identity Firewall with Auth.js (NextAuth v5) sessions. Instead of passing identity via a request header, the middleware verifies the Twingate JWT and mints an Auth.js session cookie. This gives you auth() in Server Components and useSession() in Client Components.
Last updated 3 hours ago