Add the saml response form
This commit is contained in:
parent
a00cabb2ad
commit
92e9c5489d
@ -66,27 +66,59 @@ const extractCert = (certificate: string) => {
|
||||
.trim();
|
||||
};
|
||||
|
||||
// Create SAML Response XML
|
||||
const createSAMLResponseXML = async (user: User): Promise<string> => {
|
||||
const xmlPath = path.join('data', 'saml-response.xml');
|
||||
const xml = await fs.readFile(xmlPath, 'utf8');
|
||||
// Create SAMLResponse
|
||||
const createSAMLResponse = async (user: User): Promise<string> => {
|
||||
|
||||
|
||||
return xml
|
||||
.replace(
|
||||
/idp_entity_id/g,
|
||||
'https://accounts.google.com/o/saml2?idpid=C02frd9s1'
|
||||
)
|
||||
.replace('sp_acs_url', 'some-url')
|
||||
.replace(/user_email/g, 'kiran@demo.com')
|
||||
.replace('user_firstName', 'Kiran')
|
||||
.replace('user_lastName', 'K');
|
||||
return "";
|
||||
|
||||
// const xmlPath = path.join('data', 'saml-response.xml');
|
||||
// const xml = await fs.readFile(xmlPath, 'utf8');
|
||||
|
||||
// return xml
|
||||
// .replace(
|
||||
// /idp_entity_id/g,
|
||||
// 'https://accounts.google.com/o/saml2?idpid=C02frd9s1'
|
||||
// )
|
||||
// .replace('sp_acs_url', 'some-url')
|
||||
// .replace(/user_email/g, 'kiran@demo.com')
|
||||
// .replace('user_firstName', 'Kiran')
|
||||
// .replace('user_lastName', 'K');
|
||||
};
|
||||
|
||||
//
|
||||
// base64 encode
|
||||
|
||||
export const createResponseForm = (relayState: string, samlResponse: string, acsUrl: string) => {
|
||||
const formElements = [
|
||||
'<!DOCTYPE html>',
|
||||
'<html>',
|
||||
'<head>',
|
||||
'<meta charset="utf-8">',
|
||||
'<meta http-equiv="x-ua-compatible" content="ie=edge">',
|
||||
'</head>',
|
||||
'<body onload="document.forms[0].submit()">',
|
||||
'<noscript>',
|
||||
'<p>Note: Since your browser does not support JavaScript, you must press the Continue button once to proceed.</p>',
|
||||
'</noscript>',
|
||||
'<form method="post" action="' + encodeURI(acsUrl) + '">',
|
||||
'<input type="hidden" name="RelayState" value="' + relayState + '"/>',
|
||||
'<input type="hidden" name="SAMLResponse" value="' + samlResponse + '"/>',
|
||||
'<input type="submit" value="Continue" />',
|
||||
'</form>',
|
||||
'<script>document.forms[0].style.display="none";</script>',
|
||||
'</body>',
|
||||
'</html>',
|
||||
];
|
||||
|
||||
return formElements.join('');
|
||||
};
|
||||
|
||||
export {
|
||||
parseXML,
|
||||
extractSAMLRequestAttributes,
|
||||
createIdPMetadataXML,
|
||||
createSAMLResponseXML,
|
||||
createSAMLResponse,
|
||||
createCertificate,
|
||||
extractCert,
|
||||
};
|
||||
Loading…
Reference in New Issue
Block a user