add logs
This commit is contained in:
@@ -32,6 +32,8 @@ export interface JwtPayload {
|
||||
|
||||
@Injectable()
|
||||
export class KeycloakJwtStrategy extends PassportStrategy(Strategy, 'jwt') {
|
||||
private readonly logger = new Logger(KeycloakJwtStrategy.name);
|
||||
|
||||
constructor() {
|
||||
const baseUrl = process.env.KEYCLOAK_URL ?? 'https://auth.clipperia.com.br';
|
||||
|
||||
@@ -45,19 +47,16 @@ export class KeycloakJwtStrategy extends PassportStrategy(Strategy, 'jwt') {
|
||||
}),
|
||||
algorithms: ['RS256'],
|
||||
issuer: `${baseUrl}/realms/clipperia`,
|
||||
audience: 'account',
|
||||
ignoreExpiration: false,
|
||||
});
|
||||
}
|
||||
|
||||
private readonly logger = new Logger(KeycloakJwtStrategy.name);
|
||||
this.logger.verbose(`Using Keycloak URL: ${baseUrl}`);
|
||||
}
|
||||
|
||||
validate(payload: JwtPayload): JwtPayload {
|
||||
try {
|
||||
// Basic JWT info
|
||||
this.logger.verbose('=== JWT Validation Start ===');
|
||||
|
||||
// Token metadata
|
||||
this.logger.verbose(`Subject (sub): ${payload.sub}`);
|
||||
this.logger.verbose(`Issuer (iss): ${payload.iss}`);
|
||||
this.logger.verbose(`Audience (aud): ${JSON.stringify(payload.aud)}`);
|
||||
@@ -67,8 +66,6 @@ export class KeycloakJwtStrategy extends PassportStrategy(Strategy, 'jwt') {
|
||||
this.logger.verbose(
|
||||
`Expiration (exp): ${new Date(payload.exp * 1000).toISOString()}`,
|
||||
);
|
||||
|
||||
// User info
|
||||
this.logger.verbose('--- User Info ---');
|
||||
this.logger.verbose(`Email: ${payload.email || 'N/A'}`);
|
||||
this.logger.verbose(`Username: ${payload.preferred_username || 'N/A'}`);
|
||||
|
||||
Reference in New Issue
Block a user