chore(deps): upgrade openid-client to 5.7.0

Signed-off-by: Erik Michelson <github@erik.michelson.eu>
This commit is contained in:
Erik Michelson 2024-11-12 10:41:27 +01:00
parent 5c81aec5a3
commit b194f3433c
4 changed files with 21 additions and 16 deletions

View file

@ -6,11 +6,13 @@
import {
Controller,
Get,
InternalServerErrorException,
Param,
Redirect,
Req,
UnauthorizedException,
} from '@nestjs/common';
import { HttpException } from '@nestjs/common/exceptions/http.exception';
import { ApiTags } from '@nestjs/swagger';
import { IdentityService } from '../../../../identity/identity.service';
@ -56,7 +58,7 @@ export class OidcController {
@Get(':oidcIdentifier/callback')
@Redirect()
@OpenApi(201, 400, 401)
@OpenApi(201, 400, 401, 500)
async callback(
@Param('oidcIdentifier') oidcIdentifier: string,
@Req() request: RequestWithSession,
@ -68,7 +70,7 @@ export class OidcController {
);
const oidcUserIdentifier = request.session.providerUserId;
if (!oidcUserIdentifier) {
throw new Error('No OIDC user identifier found');
throw new UnauthorizedException('No OIDC user identifier found');
}
const identity = await this.oidcService.getExistingOidcIdentity(
oidcIdentifier,
@ -94,11 +96,14 @@ export class OidcController {
return { url: '/new-user' };
}
} catch (error) {
if (error instanceof HttpException) {
throw error;
}
this.logger.log(
'Error during OIDC callback:' + String(error),
'Error during OIDC callback: ' + String(error),
'callback',
);
throw new UnauthorizedException();
throw new InternalServerErrorException();
}
}
}

View file

@ -108,8 +108,8 @@ export class OidcService {
};
}
// Update all client configs every sunday on 3:30 AM
@Cron('30 3 * * 0')
// Update all client configs every day on 3:30 AM
@Cron('30 3 * * *')
handleCronUpdateClientConfigs(): void {
this.updateClientConfigs();
}
@ -188,8 +188,8 @@ export class OidcService {
const state = request.session.oidcLoginState;
const isAutodiscovered = clientConfig.config.authorizeUrl === undefined;
const callbackMethod = isAutodiscovered
? client.callback.bind(this)
: client.oauthCallback.bind(this);
? client.callback.bind(client)
: client.oauthCallback.bind(client);
const tokenSet = await callbackMethod(clientConfig.redirectUri, params, {
// eslint-disable-next-line @typescript-eslint/naming-convention
code_verifier: code,