fix and update
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
import { Body, Controller, Get, Headers, Param, Post, Req } from '@nestjs/common';
|
||||
import { Body, Controller, ForbiddenException, Get, Headers, Param, Post, Req } from '@nestjs/common';
|
||||
import type { Request } from 'express';
|
||||
import { firstValueFrom } from 'rxjs';
|
||||
import { enrichAuthClientMeta } from '../client-request.util';
|
||||
import { JwtService } from '@nestjs/jwt';
|
||||
import { ApiBearerAuth, ApiBody, ApiOperation, ApiParam, ApiResponse, ApiTags } from '@nestjs/swagger';
|
||||
import { CoreGrpcService } from '../core-grpc.service';
|
||||
import { QrSessionDto, WebAuthnDto } from '../dto/identity.dto';
|
||||
import { resolveAuthorizedPayload } from '../session-auth';
|
||||
import { resolveFrontendUrl } from '../lib/oauth-issuer';
|
||||
|
||||
@ApiTags('Биометрия и QR-вход')
|
||||
@Controller('auth/advanced')
|
||||
@@ -53,6 +55,30 @@ export class AdvancedAuthController {
|
||||
return this.core.advancedAuth.PollQrSession({ sessionId });
|
||||
}
|
||||
|
||||
@Post('qr/session/:sessionId/claim')
|
||||
@ApiOperation({
|
||||
summary: 'Привязать QR-сессию к устройству',
|
||||
description: 'Новое устройство подтверждает сканирование QR-кода для подключения из раздела «Безопасность».'
|
||||
})
|
||||
@ApiParam({ name: 'sessionId', description: 'ID QR-сессии' })
|
||||
@ApiBody({ type: QrSessionDto })
|
||||
@ApiResponse({ status: 201, description: 'QR-сессия привязана к устройству' })
|
||||
claimQr(@Param('sessionId') sessionId: string, @Body() dto: QrSessionDto, @Req() req: Request) {
|
||||
const enriched = enrichAuthClientMeta(req, {
|
||||
deviceName: dto.deviceName,
|
||||
fingerprint: dto.fingerprint,
|
||||
deviceType: dto.deviceType ?? 'WEB'
|
||||
});
|
||||
return this.core.advancedAuth.ClaimQrSession({
|
||||
sessionId,
|
||||
deviceName: enriched.deviceName,
|
||||
fingerprint: enriched.fingerprint,
|
||||
deviceType: enriched.deviceType,
|
||||
ipAddress: enriched.ipAddress,
|
||||
userAgent: enriched.userAgent
|
||||
});
|
||||
}
|
||||
|
||||
@Post('qr/session/:sessionId/approve')
|
||||
@ApiBearerAuth()
|
||||
@ApiOperation({ summary: 'Подтвердить QR-вход', description: 'Подтверждает QR-сессию с мобильного приложения уже авторизованным пользователем.' })
|
||||
|
||||
Reference in New Issue
Block a user