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/controllers/authentication/saml/login-request.js

42 lines
783 B
JavaScript

const Errors = {
INVALID_ID: {
invalidId: 'Invalid authentication provider ID',
},
BAD_CONFIGURATION: {
badConfiguration: 'Bad SAML configuration',
},
};
module.exports = {
inputs: {
id: {
type: 'string',
required: true,
},
},
exits: {
invalidId: {
responseType: 'notFound',
},
badConfiguration: {
responseType: 'serverError',
},
},
async fn(inputs) {
const { sp, idp } = await sails.helpers.saml.getConfig(inputs.id);
const url = await new Promise((resolve, reject) => {
sp.create_login_request_url(idp, {}, (err, loginUrl) => {
if (err != null) {
reject(Errors.BAD_CONFIGURATION);
}
resolve(loginUrl);
});
});
return { item: url };
},
};