mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-09-07 18:55:42 +00:00
fix fayda
This commit is contained in:
@@ -38,7 +38,8 @@ async function bootstrap() {
|
|||||||
maxAge: 86400, // cache preflight for 24h to cut chatter in dev
|
maxAge: 86400, // cache preflight for 24h to cut chatter in dev
|
||||||
});
|
});
|
||||||
|
|
||||||
app.setGlobalPrefix("api");
|
// /callback stays un-prefixed: it's the Fayda OAuth redirect_uri ack endpoint.
|
||||||
|
app.setGlobalPrefix("api", { exclude: ["callback"] });
|
||||||
// enableImplicitConversion is OFF: class-transformer's implicit boolean
|
// enableImplicitConversion is OFF: class-transformer's implicit boolean
|
||||||
// coercion turns any non-empty multipart/form-data string (including the
|
// coercion turns any non-empty multipart/form-data string (including the
|
||||||
// literal "false") into `true`, silently corrupting flags like isHazardous
|
// literal "false") into `true`, silently corrupting flags like isHazardous
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
import { Controller, Get, Query } from '@nestjs/common';
|
||||||
|
import { ApiOkResponse, ApiOperation, ApiTags } from '@nestjs/swagger';
|
||||||
|
import { IsPublic } from '@tria-plc/api-common/modules/auth/decorators/public.decorator';
|
||||||
|
import { VerifaydaCallbackDto } from './verifayda.dto';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Plain acknowledgement endpoint for the Fayda redirect_uri when it points at
|
||||||
|
* the API instead of the web app (e.g. MOBILE clients or connectivity checks).
|
||||||
|
* Registered at /callback (excluded from the global /api prefix in main.ts).
|
||||||
|
* It does NOT consume the verification session — the client must still call
|
||||||
|
* GET /api/fayda/verification/complete with the echoed code+state.
|
||||||
|
*/
|
||||||
|
@ApiTags('Fayda Verification')
|
||||||
|
@Controller('callback')
|
||||||
|
export class FaydaCallbackController {
|
||||||
|
@Get()
|
||||||
|
@IsPublic()
|
||||||
|
@ApiOperation({ summary: 'Acknowledge a Fayda redirect (returns OK, echoes code/state)' })
|
||||||
|
@ApiOkResponse({
|
||||||
|
schema: { example: { status: 'ok', code: '...', state: '...' } },
|
||||||
|
})
|
||||||
|
ok(@Query() query: VerifaydaCallbackDto) {
|
||||||
|
return {
|
||||||
|
status: 'ok',
|
||||||
|
...(query.code ? { code: query.code } : {}),
|
||||||
|
...(query.state ? { state: query.state } : {}),
|
||||||
|
...(query.error ? { error: query.error } : {}),
|
||||||
|
...(query.error_description ? { error_description: query.error_description } : {}),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,12 +1,13 @@
|
|||||||
import { Module } from '@nestjs/common';
|
import { Module } from '@nestjs/common';
|
||||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||||
import { VerifaydaController } from './verifayda.controller';
|
import { VerifaydaController } from './verifayda.controller';
|
||||||
|
import { FaydaCallbackController } from './fayda-callback.controller';
|
||||||
import { VerifaydaService } from './verifayda.service';
|
import { VerifaydaService } from './verifayda.service';
|
||||||
import { FaydaVerificationSession } from './entities/fayda-verification-session.entity';
|
import { FaydaVerificationSession } from './entities/fayda-verification-session.entity';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [TypeOrmModule.forFeature([FaydaVerificationSession])],
|
imports: [TypeOrmModule.forFeature([FaydaVerificationSession])],
|
||||||
controllers: [VerifaydaController],
|
controllers: [VerifaydaController, FaydaCallbackController],
|
||||||
providers: [VerifaydaService],
|
providers: [VerifaydaService],
|
||||||
exports: [VerifaydaService],
|
exports: [VerifaydaService],
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user