mirror of
https://github.com/immich-app/immich.git
synced 2024-12-25 10:43:13 +02:00
fix(server/oauth): Handle errors from OAuth Discovery. (#4678)
This commit is contained in:
parent
f0dd1d715a
commit
c653e0f261
@ -221,7 +221,7 @@ export class AuthService {
|
||||
}
|
||||
|
||||
const client = await this.getOAuthClient(config);
|
||||
const url = await client.authorizationUrl({
|
||||
const url = client.authorizationUrl({
|
||||
redirect_uri: this.normalize(config, dto.redirectUri),
|
||||
scope: config.oauth.scope,
|
||||
state: generators.state(),
|
||||
@ -331,6 +331,7 @@ export class AuthService {
|
||||
response_types: ['code'],
|
||||
};
|
||||
|
||||
try {
|
||||
const issuer = await Issuer.discover(issuerUrl);
|
||||
const algorithms = (issuer.id_token_signing_alg_values_supported || []) as string[];
|
||||
if (algorithms[0] === 'HS256') {
|
||||
@ -338,6 +339,10 @@ export class AuthService {
|
||||
}
|
||||
|
||||
return new issuer.Client(metadata);
|
||||
} catch (error: Error | any) {
|
||||
this.logger.error(`Error in OAuth discovery: ${error}`, error?.stack);
|
||||
throw new InternalServerErrorException(`Error in OAuth discovery: ${error}`, { cause: error });
|
||||
}
|
||||
}
|
||||
|
||||
private normalize(config: SystemConfig, redirectUri: string) {
|
||||
|
Loading…
Reference in New Issue
Block a user