Configuration reference

Configuration reference for nuxt-oidc-auth

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)

OptionTypeDefaultDescription
enabledbooleantrueEnables/disables the module
defaultProviderProviderKeysundefinedSets the default provider. Enables automatic registration of generic /auth/login and /auth/logout route rules
providersPartial<ProviderConfigs>{}Configuration entries for each configured provider. For provider specific config see Provider specific configurations
sessionOmit<AuthSessionConfig, 'singleSignOutIdField' | 'singleSignOut'>Global session configurationOptional global session configuration
middlewareMiddlewareConfigMiddleware configurationOptional middleware specific configuration
devModeDevModeConfigDev Mode configurationConfiguration for local dev mode
devtoolsbooleantrueEnables/disables Nuxt DevTools integration for this module
provideDefaultSecretsbooleantrueProvide 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>

OptionTypeDefaultDescription
clientIdstring''Client ID
clientSecretstring''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)codeResponse Type
authenticationScheme'header' | 'body' | 'none' (optional)headerToken endpoint client authentication scheme. Use none for public clients.
responseMode'query' | 'fragment' | 'form_post' | string (optional)-Response mode for authentication request
authorizationUrlstring (optional)''Authorization endpoint URL
tokenUrlstring (optional)''Token endpoint URL
userInfoUrlstring (optional)''Userinfo endpoint URL
redirectUristring (optional)''Redirect URI
grantType'authorization_code' | 'refresh_token' (optional)authorization_codeGrant Type
scopestring[] (optional)['openid']Scope
pkceboolean (optional)falseUse PKCE (Proof Key for Code Exchange)
stateboolean (optional)trueUse state parameter with a random value. If state is not used, the nonce parameter is used to identify the flow.
nonceboolean (optional)falseUse nonce parameter with a random value.
userNameClaimstring (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.
optionalClaimsstring[] (optional)[]Claims to be extracted from the id token
logoutUrlstring (optional)''Logout endpoint URL
logoutRedirectUristring (optional)undefinedRedirect URI appended to the logout endpoint if configured
scopeInTokenRequestboolean (optional)falseInclude scope in token request
tokenRequestType'form' | 'form-urlencoded' | 'json' (optional)'form'Token request type
audiencestring (optional)-Audience used for token validation (not included in requests by default, use additionalTokenParameters or additionalAuthParameters to add it)
requiredPropertiesstring[]['clientId', 'redirectUri', 'clientSecret', 'authorizationUrl', 'tokenUrl']Required properties validated after runtime resolution. clientSecret is ignored only when authenticationScheme is none.
filterUserInfostring[] (optional)undefinedFilter userinfo response to only include these properties.
skipAccessTokenParsingboolean (optional)falseSkip access token parsing (for providers that don't follow the OIDC spec/don't issue JWT access tokens).
logoutRedirectParameterNamestring (optional)''Query parameter name for logout redirect. Will be appended to the logoutUrl as a query parameter.
additionalAuthParametersRecord<string, string> (optional)undefinedAdditional parameters to be added to the authorization request. See Provider specific configurations for possible parameters.
additionalTokenParametersRecord<string, string> (optional)undefinedAdditional parameters to be added to the token request. See Provider specific configurations for possible parameters.
additionalLogoutParametersRecord<string, string> (optional)undefinedAdditional parameters to be added to the logout request. See Provider specific configurations for possible parameters.
baseUrlstring (optional)''Provider Only. Base URL for the provider, used when to dynamically create authorizationUrl, tokenUrl, userInfoUrl and logoutUrl if possible.
openIdConfigurationstring, Record<string, unknown>, or function (config) => Promise<Record<string, unknown>> (optional)undefinedOpenID Configuration URL, object, or function that resolves to an OpenID Configuration object.
validateAccessTokenboolean (optional)trueValidate access token.
validateIdTokenboolean (optional)trueValidate 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.
encodeRedirectUriboolean (optional)falseEncode redirect uri query parameter in authorization request. Only for compatibility with services that don't implement proper parsing of query parameters.
exposeAccessTokenboolean (optional)falseExpose access token to the client within session object
exposeIdTokenboolean (optional)falseExpose raw id token to the client within session object
callbackRedirectUrlstring (optional)/Set a custom redirect url after a successful callback. If explicitly configured, it takes precedence over middleware-provided callbackRedirectUrl values
allowedCallbackRedirectUrlsstring[] (optional)[]Allowlist for redirect query parameters used on callback routes
allowedClientAuthParametersstring[] (optional)[]List of allowed client-side user-added query parameters for the auth request
proxystring (optional)undefinedProxy URL used for outbound requests to this provider
ignoreProxyCertificateErrorsboolean (optional)falseDisable proxy certificate validation (development only, insecure for production)
sessionConfigurationProviderSessionConfig (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.

OptionTypeDefaultDescription
cookieNamestring'nuxt-oidc-auth'Cookie name used for the user session
automaticRefreshbooleantrueAutomatically refresh access token and session if refresh token is available (indicated by canRefresh property on user object)
expirationCheckbooleantrueCheck if session is expired based on access token exp
expirationThresholdnumber0Amount 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
maxAgenumber60 * 60 * 24 (1 day)Maximum user session duration in seconds
maxAuthSessionAgenumber300 (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.

OptionTypeDefaultDescription
cookieNamestring'nuxt-oidc-auth'Cookie name used for the user session for this provider
automaticRefreshbooleantrueAutomatically refresh access token and session if refresh token is available (indicated by canRefresh property on user object)
expirationCheckbooleantrueCheck if session is expired based on access token exp
expirationThresholdnumber0Amount of seconds before access token expiration to trigger automatic refresh
missingPersistentSession'clear' | 'warn' | 'silent''clear'Overrides global behavior for missing persistent session entries
maxAuthSessionAgenumberInherits global valueMaximum OAuth flow/auth session duration in seconds for this provider
singleSignOutbooleanfalseEnable 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)

OptionTypeDefaultDescription
globalMiddlewareEnabledbooleantrueEnables/disables the global middleware
redirectbooleantrueEnables/disables automatic redirect to login when user is unauthenticated
customLoginPagebooleanfalseEnables/disables automatic registration of /auth/login route rule
customLogoutPagebooleanfalseEnables/disables automatic registration of /auth/logout route rule

Dev Mode configuration (devMode)

For more details, please check the dev mode docs page

OptionTypeDefaultDescription
enabledbooleanfalseEnables/disables the dev mode. Dev mode can only be enabled when the app runs in a non production environment.
userNamestring'Nuxt OIDC Auth Dev'Sets the userName field on the user object
userInfoRecord<string, unknown>undefinedSets the userInfo field on the user object
tokenAlgorithm'symmetric' | 'asymmetric''asymmetric'Sets the key algorithm for signing generated JWT tokens
idTokenstringundefinedSets the idToken field on the user object
accessTokenstringundefinedSets the accessToken field on the user object
claimsRecord<string, string>undefinedSets the claims field on the user object and generated JWT token if generateAccessToken is set to true
generateAccessTokenbooleanfalseIf set, generates a JWT token for the accessToken field based on the given user information
issuerstring'nuxt:oidc:auth:issuer'Only used with generateAccessToken. Sets the issuer field on the generated JWT token
audiencestring'nuxt:oidc:auth:audience'Only used with generateAccessToken. Sets the audience field on the generated JWT token
subjectstring'nuxt:oidc:auth:subject'Only used with generateAccessToken. Sets the subject field on the generated JWT token

Example configuration

nuxt.config.ts
  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',
    },
  },