Merge pull request #3964 from lowjoel/saml-fixes

fix(auth-backend/saml): Add checks for blank cert and implement logout configs
This commit is contained in:
Fredrik Adelöw
2021-01-12 08:58:18 +01:00
committed by GitHub
3 changed files with 12 additions and 0 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-auth-backend': patch
---
Allow blank certificates and support logout URLs in the SAML provider.
+1
View File
@@ -46,6 +46,7 @@ export interface Config {
};
saml?: {
entryPoint: string;
logoutUrl?: string;
issuer: string;
cert?: string;
privateKey?: string;
@@ -129,6 +129,7 @@ export const createSamlProvider: AuthProviderFactory = ({
const opts = {
callbackUrl: `${globalConfig.baseUrl}/${providerId}/handler/frame`,
entryPoint: config.getString('entryPoint'),
logoutUrl: config.getOptionalString('logoutUrl'),
issuer: config.getString('issuer'),
cert: config.getOptionalString('cert'),
privateCert: config.getOptionalString('privateKey'),
@@ -142,5 +143,10 @@ export const createSamlProvider: AuthProviderFactory = ({
appUrl: globalConfig.appUrl,
};
// passport-saml will return an error if the `cert` key is set, and the value is empty.
// Since we read from config (such as environment variables) an empty string should be equal to being unset.
if (!opts.cert) {
delete opts.cert;
}
return new SamlAuthProvider(opts);
};