Overview
Nuxt OIDC Auth is a Nuxt module designed for native OIDC-based authentication, providing a high level of customization and security for SSR applications. This module stands out for its focus on native OIDC with minimal external dependencies, ensuring a secure authentication process. It offers various features such as secured cookie sessions, OpenID Connect provider configuration, support for multiple providers, and server-side token storage.
Features
- Secured & sealed cookies sessions: Ensures secure sessions through encrypted cookies.
- Generic spec compliant OpenID connect provider: Fully configurable OIDC flow with state, nonce, PKCE, and token request.
- Presets for popular OIDC providers: Offers presets for easy configuration with popular OIDC providers.
- Multi-provider support: Automatically registers routes for different providers for login, logout, and callback.
- useOidcAuth composable: Facilitates user information retrieval, login/logout actions, session refreshing, and token refresh triggering.
- Encrypted server-side refresh/access token storage: Utilizes unstorage for secure token storage on the server side.
- Optional global middleware: Provides automatic redirection to default provider or custom login page.
- Optional token validation and session expiration checking.
Installation
- Add
nuxt-oidc-auth
as a dependency to your project. - Include
nuxt-oidc-auth
in the modules section ofnuxt.config.ts
. - Configure the secrets:
- Set
NUXT_OIDC_SESSION_SECRET
,NUXT_OIDC_TOKEN_KEY
, andNUXT_OIDC_AUTH_SESSION_SECRET
in the environment variables or.env
file. - Manually set these secrets in production for security.
- Reference the provided example for generating random secrets.
- Set
- Configure the secrets and environment variables, and you are all set!
Summary
Nuxt OIDC Auth is a comprehensive module for implementing OIDC-based authentication in Nuxt applications. It offers various features for secure authentication flows, token management, and provider integration. By following the easy setup guide and configuring the required secrets, developers can leverage the functionalities of this module to enhance the security and customization of their SSR applications.