check for missing signature and throw appropriate error (#80)
This commit is contained in:
parent
e2ecfd28d5
commit
929fac62dd
@ -42,6 +42,6 @@ async function processSAMLRequest(req: NextApiRequest, res: NextApiResponse, isP
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
|
||||
res.status(500).send(`Error parsing SAML request`);
|
||||
res.status(500).send(`${err}`);
|
||||
}
|
||||
}
|
||||
|
||||
@ -31,13 +31,20 @@ const extractSAMLRequestAttributes = async (rawRequest: string) => {
|
||||
const attributes = result['samlp:AuthnRequest']['$'];
|
||||
const issuer = result['samlp:AuthnRequest']['saml:Issuer'];
|
||||
|
||||
const publicKey = result['samlp:AuthnRequest']['Signature']
|
||||
? result['samlp:AuthnRequest']['Signature']['KeyInfo'][0]['X509Data'][0]['X509Certificate'][0]
|
||||
: null;
|
||||
|
||||
if (!publicKey) {
|
||||
throw new Error('Missing signature');
|
||||
}
|
||||
|
||||
return {
|
||||
id: attributes.ID,
|
||||
acsUrl: attributes.AssertionConsumerServiceURL,
|
||||
providerName: attributes.ProviderName,
|
||||
audience: issuer[0]['_'],
|
||||
publicKey:
|
||||
result['samlp:AuthnRequest']['Signature'][0]['KeyInfo'][0]['X509Data'][0]['X509Certificate'][0],
|
||||
publicKey,
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user