Add the saml response form
This commit is contained in:
parent
a00cabb2ad
commit
92e9c5489d
@ -66,27 +66,59 @@ const extractCert = (certificate: string) => {
|
|||||||
.trim();
|
.trim();
|
||||||
};
|
};
|
||||||
|
|
||||||
// Create SAML Response XML
|
// Create SAMLResponse
|
||||||
const createSAMLResponseXML = async (user: User): Promise<string> => {
|
const createSAMLResponse = async (user: User): Promise<string> => {
|
||||||
const xmlPath = path.join('data', 'saml-response.xml');
|
|
||||||
const xml = await fs.readFile(xmlPath, 'utf8');
|
|
||||||
|
|
||||||
return xml
|
return "";
|
||||||
.replace(
|
|
||||||
/idp_entity_id/g,
|
// const xmlPath = path.join('data', 'saml-response.xml');
|
||||||
'https://accounts.google.com/o/saml2?idpid=C02frd9s1'
|
// const xml = await fs.readFile(xmlPath, 'utf8');
|
||||||
)
|
|
||||||
.replace('sp_acs_url', 'some-url')
|
// return xml
|
||||||
.replace(/user_email/g, 'kiran@demo.com')
|
// .replace(
|
||||||
.replace('user_firstName', 'Kiran')
|
// /idp_entity_id/g,
|
||||||
.replace('user_lastName', 'K');
|
// '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 {
|
export {
|
||||||
parseXML,
|
parseXML,
|
||||||
extractSAMLRequestAttributes,
|
extractSAMLRequestAttributes,
|
||||||
createIdPMetadataXML,
|
createIdPMetadataXML,
|
||||||
createSAMLResponseXML,
|
createSAMLResponse,
|
||||||
createCertificate,
|
createCertificate,
|
||||||
extractCert,
|
extractCert,
|
||||||
};
|
};
|
||||||
Loading…
Reference in New Issue
Block a user