change public app name for oauth
This commit is contained in:
@@ -5,7 +5,7 @@ import { firstValueFrom } from 'rxjs';
|
||||
import { CoreGrpcService } from '../core-grpc.service';
|
||||
import { OAuthAuthorizeIncomingDto, OAuthConsentActionDto, OAuthTokenIncomingDto } from '../dto/oauth.dto';
|
||||
import { extractBearerToken } from '../auth-token';
|
||||
import { appendQueryParams, mapUserInfoToOidc, mergeTokenCredentials, mapTokenResponseToStandard, normalizeAuthorizeQuery, normalizeConsentQuery, normalizeTokenBody } from '../lib/oauth-params';
|
||||
import { appendQueryParams, mapOAuthClientPublicInfo, mapOAuthConsentCheckResponse, mapUserInfoToOidc, mapUserOAuthConsentsResponse, mergeTokenCredentials, mapTokenResponseToStandard, normalizeAuthorizeQuery, normalizeConsentQuery, normalizeTokenBody } from '../lib/oauth-params';
|
||||
import { resolveFrontendUrl } from '../lib/oauth-issuer';
|
||||
import { verifyAccessToken } from '../session-auth';
|
||||
|
||||
@@ -87,13 +87,14 @@ export class OAuthController {
|
||||
|
||||
if (!consentCheck.granted) {
|
||||
if (wantsJson) {
|
||||
return (await firstValueFrom(
|
||||
const pendingConsent = (await firstValueFrom(
|
||||
this.core.oauth.CheckOAuthConsent({
|
||||
userId,
|
||||
clientId: normalized.clientId,
|
||||
scope: normalized.scope
|
||||
})
|
||||
)) as Record<string, unknown>;
|
||||
return mapOAuthConsentCheckResponse(pendingConsent);
|
||||
}
|
||||
const frontendUrl = await resolveFrontendUrl(this.core);
|
||||
const consentQuery = { ...(query as Record<string, unknown>) };
|
||||
@@ -139,13 +140,26 @@ export class OAuthController {
|
||||
) {
|
||||
const payload = await verifyAccessToken(this.jwt, authorization);
|
||||
const normalized = normalizeConsentQuery(query as Record<string, unknown>);
|
||||
return firstValueFrom(
|
||||
const result = (await firstValueFrom(
|
||||
this.core.oauth.CheckOAuthConsent({
|
||||
userId: payload.sub,
|
||||
clientId: normalized.clientId,
|
||||
scope: normalized.scope
|
||||
})
|
||||
);
|
||||
)) as Record<string, unknown>;
|
||||
return mapOAuthConsentCheckResponse(result);
|
||||
}
|
||||
|
||||
@Get('clients/:clientId/public')
|
||||
@ApiOperation({
|
||||
summary: 'Публичная информация об OAuth-приложении',
|
||||
description: 'Возвращает человекочитаемое название приложения для экрана согласия.'
|
||||
})
|
||||
async getClientPublicInfo(@Param('clientId') clientId: string) {
|
||||
const result = (await firstValueFrom(
|
||||
this.core.oauth.GetOAuthClientPublicInfo({ clientId })
|
||||
)) as Record<string, unknown>;
|
||||
return mapOAuthClientPublicInfo(result);
|
||||
}
|
||||
|
||||
@Post('consent/approve')
|
||||
@@ -186,7 +200,8 @@ export class OAuthController {
|
||||
if (payload.sub !== userId) {
|
||||
throw new UnauthorizedException('Можно просматривать только свои согласия');
|
||||
}
|
||||
return firstValueFrom(this.core.oauth.ListUserOAuthConsents({ userId }));
|
||||
const result = (await firstValueFrom(this.core.oauth.ListUserOAuthConsents({ userId }))) as Record<string, unknown>;
|
||||
return mapUserOAuthConsentsResponse(result);
|
||||
}
|
||||
|
||||
@Delete('consents/users/:userId/:consentId')
|
||||
|
||||
Reference in New Issue
Block a user