Add signing certificate to SAML auth

This commit is contained in:
yflory 2023-10-30 17:14:27 +01:00
parent f3903d3961
commit 77e600ce80
2 changed files with 24 additions and 0 deletions

View File

@ -28,11 +28,19 @@ const getClient = (cfg, cb) => {
entryPoint: cfg.url,
issuer: cfg.issuer,
cert: cfg.cert,
privateKey: cfg.privateKey
});
cb(void 0, saml);
};
const getMetadata = (cfg, cb) => {
getClient(cfg, (err, client) => {
if (err) { return void cb(err); }
cb(null, client.generateServiceProviderMetadata(null, cfg.signingCert));
});
};
module.exports = {
type: TYPE,
getMetadata: getMetadata,
checkConfig: (cfg) => {
return cfg.url && cfg.issuer && cfg.cert;
},

16
scripts/saml-metadata.js Normal file
View File

@ -0,0 +1,16 @@
const config = require("../lib/load-config");
const SSOUtils = require('../lib/sso-utils');
const sso = config.sso;
sso.list.filter((el) => {
return el.type === 'saml';
}).forEach((cfg) => {
SSOUtils.TYPES.saml.getMetadata(cfg, (err, md) => {
console.log(`Name: ${cfg.name}`);
console.log('Metadata:');
console.log();
console.log(md);
console.log();
console.log('====================================');
});
});