createOIDCInteractionController
Package: @nauth-toolkit/oidc-provider/nestjs
Type: Controller factory
Builds the NestJS controller that bridges the OpenID Connect provider and nauth-toolkit's login. OIDCProviderModule.forRoot() calls this for you; call it directly only when registering the controller in your own module.
import { createOIDCInteractionController, DEFAULT_INTERACTION_PATH } from '@nauth-toolkit/oidc-provider/nestjs';
function createOIDCInteractionController(path?: string): Type<unknown>
Parameters
path- Path relative to any global prefix. DefaultDEFAULT_INTERACTION_PATH, which is'oidc/interaction'
Routes
| Route | Method | Bridge method | Returns |
|---|---|---|---|
:uid | GET | getState() | InteractionStateDTO |
:uid/abort | POST | abort() | InteractionRedirectDTO |
:uid/confirm | POST | completeConsent() | InteractionRedirectDTO |
:uid/login | POST | completeLogin() | InteractionRedirectDTO |
Request body for :uid/confirm (OIDCConsentBody):
| Property | Type | Required | Description |
|---|---|---|---|
approve | boolean | No | Anything but an explicit false is an approval |
scopes | string[] | No | A narrowed set of scopes to grant |
{ "approve": true, "scopes": ["openid", "email"] }
The guard arrangement
The controller applies @UseGuards(AuthGuard) at the class level and @Public() on every route. Both halves are load-bearing:
AuthGuardis not a global guard in this toolkit. Without itCURRENT_USERis never populated, and the session gate reportsno_sessionfor everyone, forever.@Public()then makes the guard optional — it attaches a user when a valid session is present and never rejects — which is required, because an anonymous caller is exactly the case that has to work in order to send someone to the login page.
Reproduce both if you write your own controller.
Example
src/oidc/my-oidc.module.ts
import { Module } from '@nestjs/common';
import { createOIDCInteractionController } from '@nauth-toolkit/oidc-provider/nestjs';
@Module({
controllers: [createOIDCInteractionController('identity/interaction')],
})
export class MyOIDCModule {}
Registering it yourself means turning the module's own registration off:
OIDCProviderModule.forRoot({ ...oidcConfig, interaction: { enabled: false } });
Related APIs
- OIDCInteractionBridge - What each route calls
- OIDCProviderModule - Registers this by default