import { Body , Controller , Get , Next , Post , Query , UsePipes , ValidationPipe , } from '@nestjs/common' ; import { LoggerService } from '@fc/logger' ; import { OidcProviderRoutes } from '@fc/oidc-provider/enums' ; import { ISessionService , Session } from '@fc/session' ; import { AppSession , AuthorizeParamsDto } from '../dto' ; @ Controller ( ) export class OidcProviderController { constructor ( private readonly logger ) { this . logger . setContext ( this . constructor . name ) ; } see https TODO see https @ Get ( OidcProviderRoutes . AUTHORIZATION ) @ UsePipes ( new ValidationPipe ( { transform : true , whitelist : true , forbidNonWhitelisted : true , } ) ) async getAuthorize ( @ Next ( ) next , @ Query ( ) query , @ Session ( 'App' ) appSession ) { const { sp_id = '' } = query ; const msg = JSON . stringify ( [ '/authorize' , 'sp_id' , sp_id ] ) ; this . logger . trace ( { msg } ) ; this . logger . trace ( { route : OidcProviderRoutes . AUTHORIZATION , method : 'GET' , name : 'OidcProviderRoutes.AUTHORIZATION' , query , } ) ; await appSession . set ( 'finalSpId' , query . sp_id ) ; return next ( ) ; } see https TODO see https @ Post ( OidcProviderRoutes . AUTHORIZATION ) @ UsePipes ( new ValidationPipe ( { transform : true , whitelist : true , forbidNonWhitelisted : true , } ) ) postAuthorize ( @ Next ( ) next , @ Body ( ) body ) { const { sp_id = '' } = body ; const msg = JSON . stringify ( [ '/authorize' , 'sp_id' , sp_id ] ) ; this . logger . trace ( { msg } ) ; this . logger . trace ( { route : OidcProviderRoutes . AUTHORIZATION , method : 'POST' , name : 'OidcProviderRoutes.AUTHORIZATION' , body , } ) ; return next ( ) ; } /**
     * This controller is used to make information available for testing purpose
     * by logging needed info.
     *
     * It then forward the request to `next` controller, in this case `oidc-provider`.
     */ @ Post ( OidcProviderRoutes . TOKEN ) postToken ( @ Next ( ) next , @ Body ( ) body ) { const { sp_id = '' } = body ; const msg = JSON . stringify ( [ '/token' , 'sp_id' , sp_id ] ) ; this . logger . trace ( { msg } ) ; return next ( ) ; } }