From a0a3e6d6cacdeb2218065c6bacf6be1485bff175 Mon Sep 17 00:00:00 2001 From: J Shamsul Bahri Date: Tue, 13 Oct 2020 12:49:16 +0800 Subject: [PATCH] Fix: SAML provider postMessageResponse localhost (#2870) * make saml provider path from globalConfig * fix:(auth-backend/saml) change hardcoded localhost Co-authored-by: JShamsul --- plugins/auth-backend/src/providers/saml/provider.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/auth-backend/src/providers/saml/provider.ts b/plugins/auth-backend/src/providers/saml/provider.ts index 59e46a86d7..a8edc9a714 100644 --- a/plugins/auth-backend/src/providers/saml/provider.ts +++ b/plugins/auth-backend/src/providers/saml/provider.ts @@ -41,8 +41,10 @@ type SamlInfo = { export class SamlAuthProvider implements AuthProviderRouteHandlers { private readonly strategy: SamlStrategy; private readonly tokenIssuer: TokenIssuer; + private readonly appUrl: string; constructor(options: SAMLProviderOptions) { + this.appUrl = options.appUrl; this.tokenIssuer = options.tokenIssuer; this.strategy = new SamlStrategy({ ...options }, (( profile: SamlProfile, @@ -82,7 +84,7 @@ export class SamlAuthProvider implements AuthProviderRouteHandlers { claims: { sub: id }, }); - return postMessageResponse(res, 'http://localhost:3000', { + return postMessageResponse(res, this.appUrl, { type: 'authorization_response', response: { providerInfo: {}, @@ -91,7 +93,7 @@ export class SamlAuthProvider implements AuthProviderRouteHandlers { }, }); } catch (error) { - return postMessageResponse(res, 'http://localhost:3000', { + return postMessageResponse(res, this.appUrl, { type: 'authorization_response', error: { name: error.name, @@ -115,6 +117,7 @@ type SAMLProviderOptions = { issuer: string; path: string; tokenIssuer: TokenIssuer; + appUrl: string; }; export const createSamlProvider: AuthProviderFactory = ({ @@ -131,6 +134,7 @@ export const createSamlProvider: AuthProviderFactory = ({ issuer, path: `${url.pathname}/${providerId}/handler/frame`, tokenIssuer, + appUrl: globalConfig.appUrl, }; return new SamlAuthProvider(opts);