You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
planka_custom/server/api/helpers/saml/get-config.js

30 lines
582 B
JavaScript

const saml2 = require('saml2-js');
module.exports = {
inputs: {
id: {
type: 'string',
required: true,
},
},
exits: {
invalidId: {},
},
async fn(inputs) {
for (let i = 0, l = sails.config.custom.samlConfig.length; i < l; i += 1) {
const config = sails.config.custom.samlConfig[i];
if (config.id === inputs.id) {
return {
sp: new saml2.ServiceProvider(config.sp),
idp: new saml2.IdentityProvider(config.idp),
bindings: config.bindings,
};
}
}
throw 'invalidId';
},
};