Skip to main content

OIDCProviderModule

Package: @nauth-toolkit/oidc-provider/nestjs Type: DynamicModule

Registers an OpenID Connect provider alongside AuthModule, along with the interaction routes your consent screen talks to.

import { OIDCProviderModule } from '@nauth-toolkit/oidc-provider/nestjs';
static forRoot(options: OIDCProviderModuleOptions): DynamicModule

The provider itself is not mounted by this module — it owns raw HTTP and must be attached to the platform adapter in main.ts. See Mounting.

Options​

OIDCProviderModuleOptions is NAuthOIDCOptions without storage and userRepository — those are resolved from AuthModule's exports — plus:

PropertyTypeRequiredDescription
interactionOIDCInteractionRouteOptionsNoHow the interaction routes are registered

OIDCInteractionRouteOptions:

PropertyTypeRequiredDescription
enabledbooleanNoRegister the shipped interaction controller. Default true
pathstringNoPath relative to any global prefix. Default 'oidc/interaction'

path must match the frontend SDK's oidc.basePath.

Injection tokens​

TokenProvides
NAUTH_OIDC_BRIDGEOIDCInteractionBridge
NAUTH_OIDC_PROVIDERThe configured Provider instance
NAUTH_OIDC_SESSIONSOIDCSessionTerminator

All three are exported, so any module in the application can inject them.

Example​

src/auth/auth.module.ts
import { Module } from '@nestjs/common';
import { AuthModule } from '@nauth-toolkit/nestjs';
import { OIDCProviderModule } from '@nauth-toolkit/oidc-provider/nestjs';
import { authConfig } from '../config/auth.config';
import { oidcConfig } from '../config/oidc.config';

@Module({
imports: [AuthModule.forRoot(authConfig), OIDCProviderModule.forRoot(oidcConfig)],
})
export class CustomAuthModule {}

Opting out of the shipped controller:

OIDCProviderModule.forRoot({ ...oidcConfig, interaction: { enabled: false } });

The bridge stays exported either way, so a hand-written controller only has to inject NAUTH_OIDC_BRIDGE.

What's Next​