Configuration reference
Configuration reference
The configuration for this module can be defined in your nuxt.config.ts file:
export default defineNuxtConfig({
oidc: {
defaultProvider: '<provider>',
providers: {
<provider>: {
clientId: '...',
clientSecret: '...'
}
},
middleware: {
globalMiddlewareEnabled: true,
customLoginPage: false
}
}
})
Global configuration (oidc)
| Option | Type | Default | Description |
|---|---|---|---|
| enabled | boolean | true | Enables/disables the module |
| defaultProvider | ProviderKeys | undefined | Sets the default provider. Enables automatic registration of generic /auth/login and /auth/logout route rules |
| providers | Partial<ProviderConfigs> | {} | Configuration entries for each configured provider. For provider specific config see Provider specific configurations |
| session | Omit<AuthSessionConfig, 'singleSignOutIdField' | 'singleSignOut'> | Global session configuration | Optional global session configuration |
| middleware | MiddlewareConfig | Middleware configuration | Optional middleware specific configuration |
| devMode | DevModeConfig | Dev Mode configuration | Configuration for local dev mode |
| devtools | boolean | true | Enables/disables Nuxt DevTools integration for this module |
| provideDefaultSecrets | boolean | true | Provide defaults for NUXT_OIDC_SESSION_SECRET, NUXT_OIDC_TOKEN_KEY and NUXT_OIDC_AUTH_SESSION_SECRET using a Nitro plugin. Turning this off can lead to the app not working if no secrets are provided |
Provider Configuration (provider)
<provider>
| Option | Type | Default | Description |
|---|---|---|---|
| clientId | string | '' | Client ID |
| clientSecret | string | '' | Client secret. Required for header and body authentication; omitted for none. |
| responseType | 'code' | 'code token' | 'code id_token' | 'id_token token' | 'code id_token token' (optional) | code | Response Type |
| authenticationScheme | 'header' | 'body' | 'none' (optional) | header | Token endpoint client authentication scheme. Use none for public clients. |
| responseMode | 'query' | 'fragment' | 'form_post' | string (optional) | - | Response mode for authentication request |
| authorizationUrl | string (optional) | '' | Authorization endpoint URL |
| tokenUrl | string (optional) | '' | Token endpoint URL |
| userInfoUrl | string (optional) | '' | Userinfo endpoint URL |
| redirectUri | string (optional) | '' | Redirect URI |
| grantType | 'authorization_code' | 'refresh_token' (optional) | authorization_code | Grant Type |
| scope | string[] (optional) | ['openid'] | Scope |
| pkce | boolean (optional) | false | Use PKCE (Proof Key for Code Exchange) |
| state | boolean (optional) | true | Use state parameter with a random value. If state is not used, the nonce parameter is used to identify the flow. |
| nonce | boolean (optional) | false | Use nonce parameter with a random value. |
| userNameClaim | string (optional) | '' | User name claim that is used to get the user name from the access token as a fallback in case the userinfo endpoint is not provided or the userinfo request fails. |
| optionalClaims | string[] (optional) | [] | Claims to be extracted from the id token |
| logoutUrl | string (optional) | '' | Logout endpoint URL |
| logoutRedirectUri | string (optional) | undefined | Redirect URI appended to the logout endpoint if configured |
| scopeInTokenRequest | boolean (optional) | false | Include scope in token request |
| tokenRequestType | 'form' | 'form-urlencoded' | 'json' (optional) | 'form' | Token request type |
| audience | string (optional) | - | Audience used for token validation (not included in requests by default, use additionalTokenParameters or additionalAuthParameters to add it) |
| requiredProperties | string[] | ['clientId', 'redirectUri', 'clientSecret', 'authorizationUrl', 'tokenUrl'] | Required properties validated after runtime resolution. clientSecret is ignored only when authenticationScheme is none. |
| filterUserInfo | string[] (optional) | undefined | Filter userinfo response to only include these properties. |
| skipAccessTokenParsing | boolean (optional) | false | Skip access token parsing (for providers that don't follow the OIDC spec/don't issue JWT access tokens). |
| logoutRedirectParameterName | string (optional) | '' | Query parameter name for logout redirect. Will be appended to the logoutUrl as a query parameter. |
| additionalAuthParameters | Record<string, string> (optional) | undefined | Additional parameters to be added to the authorization request. See Provider specific configurations for possible parameters. |
| additionalTokenParameters | Record<string, string> (optional) | undefined | Additional parameters to be added to the token request. See Provider specific configurations for possible parameters. |
| additionalLogoutParameters | Record<string, string> (optional) | undefined | Additional parameters to be added to the logout request. See Provider specific configurations for possible parameters. |
| baseUrl | string (optional) | '' | Provider Only. Base URL for the provider, used when to dynamically create authorizationUrl, tokenUrl, userInfoUrl and logoutUrl if possible. |
| openIdConfiguration | string, Record<string, unknown>, or function (config) => Promise<Record<string, unknown>> (optional) | undefined | OpenID Configuration URL, object, or function that resolves to an OpenID Configuration object. |
| validateAccessToken | boolean (optional) | true | Validate access token. |
| validateIdToken | boolean (optional) | true | Validate id token. |
| tokenValidationMode | 'legacy' | 'strict' (optional) | 'legacy' | strict validates every enabled JWT in callback and refresh token responses with token-specific audience, issuer, signature, and expiration checks. Strict access-token validation requires audience; any enabled strict validation requires OpenID discovery metadata with issuer and jwks_uri. |
| encodeRedirectUri | boolean (optional) | false | Encode redirect uri query parameter in authorization request. Only for compatibility with services that don't implement proper parsing of query parameters. |
| exposeAccessToken | boolean (optional) | false | Expose access token to the client within session object |
| exposeIdToken | boolean (optional) | false | Expose raw id token to the client within session object |
| callbackRedirectUrl | string (optional) | / | Set a custom redirect url after a successful callback. If explicitly configured, it takes precedence over middleware-provided callbackRedirectUrl values |
| allowedCallbackRedirectUrls | string[] (optional) | [] | Allowlist for redirect query parameters used on callback routes |
| allowedClientAuthParameters | string[] (optional) | [] | List of allowed client-side user-added query parameters for the auth request |
| proxy | string (optional) | undefined | Proxy URL used for outbound requests to this provider |
| ignoreProxyCertificateErrors | boolean (optional) | false | Disable proxy certificate validation (development only, insecure for production) |
| sessionConfiguration | ProviderSessionConfig (optional) | {} | Session configuration overrides, see session |
Runtime environment overrides
Every serializable provider option can be supplied through Nuxt runtime environment variables, including options omitted from nuxt.config.ts. Nested provider session fields and provider-declared additional parameters follow Nuxt's uppercase underscore naming; record and list values can also use JSON:
NUXT_OIDC_PROVIDERS_KEYCLOAK_CLIENT_ID=web-client
NUXT_OIDC_PROVIDERS_KEYCLOAK_SESSION_CONFIGURATION_MAX_AUTH_SESSION_AGE=180
NUXT_OIDC_PROVIDERS_KEYCLOAK_OPEN_ID_CONFIGURATION=https://id.example.com/realms/app/.well-known/openid-configuration
NUXT_OIDC_PROVIDERS_OIDC_ADDITIONAL_AUTH_PARAMETERS={"prompt":"consent"}
Runtime environment values take precedence over values from nuxt.config.ts and provider defaults. Functions are not serializable runtime inputs; configure openIdConfiguration as a URL when it must be changed at deployment time.
Endpoint resolution and validation
An explicitly configured endpoint takes precedence over the provider preset and baseUrl. Absolute http or https endpoints are used unchanged. Relative explicit or preset endpoints are resolved against baseUrl; a flow that needs a relative endpoint fails configuration validation when baseUrl is absent. Explicit empty userInfoUrl and logoutUrl values disable those optional endpoints.
Validation is flow-specific. Login requires its authorization inputs, callback and refresh require their token and enabled validation inputs, and logout validates only configured logout behavior. This allows configurations that provide complete absolute endpoints to omit a provider baseUrl.
Reading effective provider configuration on the server
Use useOidcProviderConfig in server routes and utilities to read resolved provider defaults,
runtime environment overrides, endpoint URLs, and provider placeholders:
export default defineEventHandler((event) => {
const github = useOidcProviderConfig(event, 'github')
return { authorizationUrl: github.authorizationUrl }
})
This helper is server-only and returns EffectiveProviderConfig for the selected provider. Values
stored directly in useRuntimeConfig(event).oidc.providers use ProviderRuntimeConfig, the raw
override shape. Do not treat that raw storage as resolved configuration or expose it to client code.
NODE_ENV is classified as production when its value starts with prod, case-insensitively. This classification controls the default secure-cookie flag and disables dev mode. Values such as production, prod, and PROD-preview are production; an unset value is non-production.
Global session configuration (session)
The following options are available for the global session configuration.
Note that singleSignOut and singleSignOutIdField are provider specific options and can only be configured in providers.<provider>.sessionConfiguration.
| Option | Type | Default | Description |
|---|---|---|---|
| cookieName | string | 'nuxt-oidc-auth' | Cookie name used for the user session |
| automaticRefresh | boolean | true | Automatically refresh access token and session if refresh token is available (indicated by canRefresh property on user object) |
| expirationCheck | boolean | true | Check if session is expired based on access token exp |
| expirationThreshold | number | 0 | Amount of seconds before access token expiration to trigger automatic refresh |
| missingPersistentSession | 'clear' | 'warn' | 'silent' | 'clear' | Behavior when a refreshable cookie session exists but the persistent session entry is missing. clear removes stale session and requires re-login, warn keeps session and logs a warning, silent keeps session without warning |
| maxAge | number | 60 * 60 * 24 (1 day) | Maximum user session duration in seconds |
| maxAuthSessionAge | number | 300 (5 minutes) | Maximum OAuth flow/auth session duration in seconds |
| cookie | { sameSite?: true | false | 'lax' | 'strict' | 'none'; secure?: boolean } | { sameSite: 'lax', secure: NODE_ENV starts with 'prod' } | Additional cookie setting overrides for sameSite and secure |
Provider session configuration
The following options are available on every provider as overrides for the global session configuration.
| Option | Type | Default | Description |
|---|---|---|---|
| cookieName | string | 'nuxt-oidc-auth' | Cookie name used for the user session for this provider |
| automaticRefresh | boolean | true | Automatically refresh access token and session if refresh token is available (indicated by canRefresh property on user object) |
| expirationCheck | boolean | true | Check if session is expired based on access token exp |
| expirationThreshold | number | 0 | Amount of seconds before access token expiration to trigger automatic refresh |
| missingPersistentSession | 'clear' | 'warn' | 'silent' | 'clear' | Overrides global behavior for missing persistent session entries |
| maxAuthSessionAge | number | Inherits global value | Maximum OAuth flow/auth session duration in seconds for this provider |
| singleSignOut | boolean | false | Enable cross-tab/browser single sign-out support |
| singleSignOutIdField | 'sub' | 'aud' | 'sub' | Token field used to derive the single sign-out session id |
Middleware configuration (middleware)
| Option | Type | Default | Description |
|---|---|---|---|
| globalMiddlewareEnabled | boolean | true | Enables/disables the global middleware |
| redirect | boolean | true | Enables/disables automatic redirect to login when user is unauthenticated |
| customLoginPage | boolean | false | Enables/disables automatic registration of /auth/login route rule |
| customLogoutPage | boolean | false | Enables/disables automatic registration of /auth/logout route rule |
Dev Mode configuration (devMode)
For more details, please check the dev mode docs page
| Option | Type | Default | Description |
|---|---|---|---|
| enabled | boolean | false | Enables/disables the dev mode. Dev mode can only be enabled when the app runs in a non production environment. |
| userName | string | 'Nuxt OIDC Auth Dev' | Sets the userName field on the user object |
| userInfo | Record<string, unknown> | undefined | Sets the userInfo field on the user object |
| tokenAlgorithm | 'symmetric' | 'asymmetric' | 'asymmetric' | Sets the key algorithm for signing generated JWT tokens |
| idToken | string | undefined | Sets the idToken field on the user object |
| accessToken | string | undefined | Sets the accessToken field on the user object |
| claims | Record<string, string> | undefined | Sets the claims field on the user object and generated JWT token if generateAccessToken is set to true |
| generateAccessToken | boolean | false | If set, generates a JWT token for the accessToken field based on the given user information |
| issuer | string | 'nuxt:oidc:auth:issuer' | Only used with generateAccessToken. Sets the issuer field on the generated JWT token |
| audience | string | 'nuxt:oidc:auth:audience' | Only used with generateAccessToken. Sets the audience field on the generated JWT token |
| subject | string | 'nuxt:oidc:auth:subject' | Only used with generateAccessToken. Sets the subject field on the generated JWT token |
Example configuration
oidc: {
defaultProvider: 'github',
providers: {
github: {
redirectUri: 'http://localhost:3000/auth/github/callback',
clientId: '',
clientSecret: '',
filterUserInfo: ['login', 'id', 'avatar_url', 'name', 'email'],
},
keycloak: {
audience: 'account',
baseUrl: '',
clientId: '',
clientSecret: '',
redirectUri: 'http://localhost:3000/auth/keycloak/callback',
userNameClaim: 'preferred_username',
},
cognito: {
clientId: '',
redirectUri: 'http://localhost:3000/auth/cognito/callback',
clientSecret: '',
scope: ['openid', 'email', 'profile'],
logoutRedirectUri: 'https://google.com',
baseUrl: '',
exposeIdToken: true,
},
zitadel: {
clientId: '',
redirectUri: 'http://localhost:3000/auth/zitadel/callback',
baseUrl: '',
audience: '', // Specify for id token validation, normally same as clientId
logoutRedirectUri: 'https://google.com', // Needs to be registered in Zitadel portal
authenticationScheme: 'none',
},
},
session: {
expirationCheck: true,
automaticRefresh: true,
expirationThreshold: 3600,
missingPersistentSession: 'clear',
},
middleware: {
globalMiddlewareEnabled: true,
customLoginPage: true,
customLogoutPage: false,
},
devMode: {
enabled: false,
generateAccessToken: true,
userName: 'Test User',
userInfo: { providerName: 'test' },
claims: { customclaim01: 'foo', customclaim02: 'bar' },
issuer: 'dev-issuer',
audience: 'dev-app',
subject: 'dev-user',
},
},

