logs
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { BadRequestException, Injectable, NotFoundException } from '@nestjs/common';
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { randomUUID } from 'node:crypto';
|
||||
import { createHash, randomUUID } from 'node:crypto';
|
||||
import { Repository } from 'typeorm';
|
||||
import { decryptSecret, encryptSecret, randomToken } from '../common/token.util';
|
||||
import { CreateOidcClientDto } from './dto/create-oidc-client.dto';
|
||||
@@ -131,7 +131,23 @@ export class OidcClientService {
|
||||
};
|
||||
|
||||
if (client.encryptedClientSecret) {
|
||||
metadata.client_secret = decryptSecret(client.encryptedClientSecret, this.tokenSecret);
|
||||
try {
|
||||
metadata.client_secret = decryptSecret(client.encryptedClientSecret, this.tokenSecret);
|
||||
} catch (error) {
|
||||
const errorMessage = error instanceof Error ? error.message : String(error);
|
||||
console.error(
|
||||
'[OIDC_CLIENT_SECRET_DECRYPT_FAILED]',
|
||||
JSON.stringify({
|
||||
clientId: client.clientId,
|
||||
clientName: client.clientName,
|
||||
tokenEndpointAuthMethod: client.tokenEndpointAuthMethod,
|
||||
tokenSecretFingerprint: this.tokenSecretFingerprint,
|
||||
encryptedClientSecretParts: client.encryptedClientSecret.split('.').length,
|
||||
errorMessage,
|
||||
}),
|
||||
);
|
||||
throw error;
|
||||
}
|
||||
metadata.client_secret_expires_at = 0;
|
||||
}
|
||||
|
||||
@@ -160,4 +176,8 @@ export class OidcClientService {
|
||||
private get tokenSecret(): string {
|
||||
return this.config.getOrThrow<string>('TOKEN_SECRET');
|
||||
}
|
||||
|
||||
private get tokenSecretFingerprint(): string {
|
||||
return createHash('sha256').update(this.tokenSecret).digest('hex').slice(0, 12);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user