diff --git a/backend/src/oauth/provider/genericOidc.provider.ts b/backend/src/oauth/provider/genericOidc.provider.ts index 72a1f4b..bec617d 100644 --- a/backend/src/oauth/provider/genericOidc.provider.ts +++ b/backend/src/oauth/provider/genericOidc.provider.ts @@ -9,7 +9,6 @@ import { OAuthProvider, OAuthToken } from "./oauthProvider.interface"; import { OAuthSignInDto } from "../dto/oauthSignIn.dto"; export abstract class GenericOidcProvider implements OAuthProvider { - protected redirectUri: string; protected discoveryUri: string; private configuration: OidcConfigurationCache; private jwk: OidcJwkCache; @@ -22,9 +21,6 @@ export abstract class GenericOidcProvider implements OAuthProvider { protected cache: Cache, ) { this.discoveryUri = this.getDiscoveryUri(); - this.redirectUri = `${this.config.get( - "general.appUrl", - )}/api/oauth/callback/${this.name}`; this.config.addListener("update", (key: string, _: unknown) => { if (this.keyOfConfigUpdateEvents.includes(key)) { this.deinit(); @@ -33,6 +29,12 @@ export abstract class GenericOidcProvider implements OAuthProvider { }); } + protected getRedirectUri(): string { + return `${this.config.get("general.appUrl")}/api/oauth/callback/${ + this.name + }`; + } + async getConfiguration(): Promise { if (!this.configuration || this.configuration.expires < Date.now()) { await this.fetchConfiguration(); @@ -65,7 +67,7 @@ export abstract class GenericOidcProvider implements OAuthProvider { client_id: this.config.get(`oauth.${this.name}-clientId`), response_type: "code", scope: "openid profile email", - redirect_uri: this.redirectUri, + redirect_uri: this.getRedirectUri(), state, nonce, }).toString() @@ -85,7 +87,7 @@ export abstract class GenericOidcProvider implements OAuthProvider { client_secret: this.config.get(`oauth.${this.name}-clientSecret`), grant_type: "authorization_code", code: query.code, - redirect_uri: this.redirectUri, + redirect_uri: this.getRedirectUri(), }).toString(), }); const token: OidcToken = await res.json();