express-openid-connect is an Express.js middleware designed to integrate OpenID Connect (OIDC) authentication into web applications, streamlining user login and session management. Currently at version 2.20.2, the library is actively maintained with a regular release cadence, frequently addressing bug fixes and introducing minor features. It abstracts away much of the complexity of OIDC flows, particularly when used with Auth0 as an identity provider, by handling authentication, logout, and session management automatically. Key differentiators include its focus on Express applications, deep integration capabilities with Auth0, and providing sensible defaults to secure web applications, while also offering extensive configuration options for advanced use cases. It ships with TypeScript types, enhancing developer experience for type-safe applications.
npm install express-openid-connectVerified import paths — ran on the pinned version, not inferred.
This quickstart initializes an Express application with OpenID Connect authentication using `express-openid-connect`. It demonstrates basic login, logout, and a protected profile route, requiring environment variables for Auth0 configuration.
Ensure the `secret` value in your configuration is a long, random string, preferably 32 characters or more, and stored securely (e.g., via environment variables).
Configure your development environment to use HTTPS (e.g., with `ngrok`, `mkcert`, or a local proxy) and ensure your `baseURL` matches your HTTPS URL (e.g., `https://localhost:3000`).
In the Auth0 Dashboard, navigate to your application's 'Settings', then 'Advanced Settings' -> 'OAuth' tab. Set 'JsonWebToken Signature Algorithm' to `RS256` and ensure 'OIDC Conformant' is enabled.
Review the `express-openid-connect` FAQ for potential workarounds or consider alternative HTTP agents if encountering proxy-related connection problems.
Ensure custom session store implementations consistently return promises for `async` operations or adhere to standard Node.js callback patterns that the library can properly promisify. Consult the documentation for `util-promisify` if using custom stores and encountering issues.
Ensure your application is accessible via HTTPS, even in development. Verify that `config.baseURL` in your code and 'Allowed Callback URLs'/'Allowed Logout URLs' in your Auth0 application settings precisely match your application's origin (e.g., `https://localhost:3000`).
Check your browser's console for any cookie-related warnings. Ensure your application uses HTTPS. If using a custom session store, verify its `get()` method correctly retrieves the state. Upgrade to `express-openid-connect@2.20.2` or newer for fixes related to missing transaction cookies.
In your Auth0 Dashboard, navigate to your application's 'Settings', then 'Advanced Settings' -> 'OAuth' tab. Set 'JsonWebToken Signature Algorithm' to `RS256` and ensure 'OIDC Conformant' is enabled.
This specific issue was addressed in `express-openid-connect@2.20.0`. Ensure you are using `v2.20.0` or a later version of the library. If the problem persists in a unique environment, consult the library's compatibility notes or report an issue.