first commit
This commit is contained in:
42
apps/api-gateway/src/controllers/advanced-auth.controller.ts
Normal file
42
apps/api-gateway/src/controllers/advanced-auth.controller.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import { Body, Controller, Get, Param, Post } from '@nestjs/common';
|
||||
import { ApiBody, ApiOperation, ApiParam, ApiResponse, ApiTags } from '@nestjs/swagger';
|
||||
import { CoreGrpcService } from '../core-grpc.service';
|
||||
import { QrSessionDto, WebAuthnDto } from '../dto/identity.dto';
|
||||
|
||||
@ApiTags('Биометрия и QR-вход')
|
||||
@Controller('auth/advanced')
|
||||
export class AdvancedAuthController {
|
||||
constructor(private readonly core: CoreGrpcService) {}
|
||||
|
||||
@Post('webauthn/register/challenge')
|
||||
@ApiOperation({ summary: 'Challenge регистрации WebAuthn', description: 'Создает challenge для регистрации лица/отпечатка. Endpoint готов для подключения настоящего WebAuthn attestation.' })
|
||||
@ApiBody({ type: WebAuthnDto })
|
||||
@ApiResponse({ status: 201, description: 'Challenge создан' })
|
||||
webAuthnRegister(@Body() dto: WebAuthnDto) {
|
||||
return this.core.advancedAuth.CreateWebAuthnRegistrationChallenge(dto);
|
||||
}
|
||||
|
||||
@Post('webauthn/login/challenge')
|
||||
@ApiOperation({ summary: 'Challenge входа WebAuthn', description: 'Создает challenge для входа по лицу или отпечатку.' })
|
||||
@ApiBody({ type: WebAuthnDto })
|
||||
@ApiResponse({ status: 201, description: 'Challenge создан' })
|
||||
webAuthnLogin(@Body() dto: WebAuthnDto) {
|
||||
return this.core.advancedAuth.CreateWebAuthnLoginChallenge(dto);
|
||||
}
|
||||
|
||||
@Post('qr/session')
|
||||
@ApiOperation({ summary: 'Создать QR-сессию', description: 'Создает временную QR-сессию для входа с другого устройства.' })
|
||||
@ApiBody({ type: QrSessionDto })
|
||||
@ApiResponse({ status: 201, description: 'QR-сессия создана' })
|
||||
createQr(@Body() dto: QrSessionDto) {
|
||||
return this.core.advancedAuth.CreateQrSession(dto);
|
||||
}
|
||||
|
||||
@Get('qr/session/:sessionId')
|
||||
@ApiOperation({ summary: 'Проверить QR-сессию', description: 'Возвращает текущий статус QR-сессии: PENDING/CONFIRMED/EXPIRED.' })
|
||||
@ApiParam({ name: 'sessionId', description: 'ID QR-сессии' })
|
||||
@ApiResponse({ status: 200, description: 'Статус QR-сессии получен' })
|
||||
pollQr(@Param('sessionId') sessionId: string) {
|
||||
return this.core.advancedAuth.PollQrSession({ sessionId });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user