Created
January 4, 2023 20:18
-
-
Save Mikej81/44ad2d5a71dea388abead7f5c25c242b to your computer and use it in GitHub Desktop.
401 Error Page Example with configurable SAMLAuthRequest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<script src="https://cdn.jsdelivr.net/gh/dankogai/js-deflate/rawdeflate.js"></script> | |
</head> | |
<body> | |
<h1>SAMLAuthnRequest Test</h1> | |
<br /> | |
To use, modify the following variables: | |
<ul> | |
<li>var consumer = window.location.href; //Service Provider</li> | |
<li>var destination = 'https://sso.domain.com/login'; //Identity Provider </li> | |
<li>var issuer = 'https://sso.domain.com'; //Identity Provider</li> | |
</ul> | |
Todo: | |
<ul> | |
<li>-what else?</li> | |
</ul> | |
<form id="login" method="POST"> | |
<input type="hidden" id="SAMLRequest" name="SAMLRequest"> | |
<button onclick="setAssertion()">Logon</button> | |
<script> | |
var consumer = window.location.href; //Service Provider | |
var destination = 'https://sso.domain.com/login'; //Identity Provider | |
var issuer = 'https://sso.domain.com'; //Identity Provider | |
var template = ` | |
'<samlp:AuthnRequest xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" ID="" Version="2.0" ProviderName="XC SP" IssueInstant="2014-07-16T23:52:45Z" | |
Destination="${destination}" ProtocolBinding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST" | |
AssertionConsumerServiceURL="${consumer}"> | |
<saml:Issuer>${issuer}</saml:Issuer> | |
<samlp:NameIDPolicy Format="urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress" AllowCreate="true" /> | |
<samlp:RequestedAuthnContext Comparison="exact"> | |
<saml:AuthnContextClassRef>urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport</saml:AuthnContextClassRef> | |
</samlp:RequestedAuthnContext> | |
</samlp:AuthnRequest>' | |
`; | |
var deflatedTemplate = RawDeflate.deflate(template); | |
//var encodedTemplate = btoa(template); | |
var encodedTemplate = btoa(deflatedTemplate); | |
function setAssertion() { | |
document.getElementById("SAMLRequest").setAttribute('value', encodedTemplate); | |
document.getElementById("login").setAttribute('action', issuer); | |
} | |
</script> | |
</form> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If !Authorization then error page.