diff --git a/modules/saml2debug/default-disable b/modules/saml2debug/default-disable new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/modules/saml2debug/hooks/hook_frontpage.php b/modules/saml2debug/hooks/hook_frontpage.php new file mode 100644 index 0000000000000000000000000000000000000000..e29146733ad66957860527ada27706cf37e4d034 --- /dev/null +++ b/modules/saml2debug/hooks/hook_frontpage.php @@ -0,0 +1,19 @@ +<?php +/** + * Hook to add the simple consenet admin module to the frontpage. + * + * @param array &$links The links on the frontpage, split into sections. + */ +function saml2debug_hook_frontpage(&$links) { + assert('is_array($links)'); + assert('array_key_exists("links", $links)'); + + $links['links'][] = array( + 'href' => SimpleSAML_Module::getModuleURL('saml2debug/debug.php'), + 'text' => array('en' => 'SAML 2.0 Degbugger'), + ); + +} + + +?> diff --git a/modules/saml2debug/templates/debug.tpl.php b/modules/saml2debug/templates/debug.tpl.php new file mode 100644 index 0000000000000000000000000000000000000000..3fdc760b7caecdb1a1450f404bd6e44a85b13aaf --- /dev/null +++ b/modules/saml2debug/templates/debug.tpl.php @@ -0,0 +1,67 @@ +<?php + +$this->data['head'] = '<script type="text/javascript" src="/' . $this->data['baseurlpath'] . 'resources/jquery.js"></script>'; +$this->data['head'] .= '<script type="text/javascript" src="/' . $this->data['baseurlpath'] . 'resources/jquery-ui.js"></script>'; +$this->data['head'] .= '<link rel="stylesheet" media="screen" type="text/css" href="/' . $this->data['baseurlpath'] . 'resources/uitheme/jquery-ui-themeroller.css" />'; + +$this->data['head'] .= '<script type="text/javascript"> + +$(document).ready(function() { + $("#tabdiv > ul").tabs({ selected: ' . $this->data['activeTab'] . ' }); +}); +</script>'; + +$this->data['header'] = 'SAML 2.0 Debugger'; +$this->includeAtTemplateBase('includes/header.php'); +?> + + + +<div id="tabdiv"> +<ul> + <li><a href="#decode">Decode</a></li> + <li><a href="#encode">Encode</a></li> +</ul> + + +<div id="decode"> + + <p>Paste in a SAML message encoded with the HTTP-POST or HTTP-REDIRECT encoding. You can both use the full URL that you copied from LiveHTTPHeaders, or you can paste in only the SAMLRequest or SAMLResponse parameter. It will be automatically detected whether you post an URL or the value it self and whether you post a HTTP-REDIRECT or HTTP-POST encoded value. enjoy!</p> + + <form method="post" action="debug.php"> + <textarea style="width: 95%; border: 1px solid #999; font-family: monospace" cols="50" rows="10" name="encoded"><?php echo $this->data['encoded']; ?></textarea> + <p><input type="submit" name="decode" value="Decode SAML message »" /></p> + </form> + +</div> <!-- #redirect --> + +<div id="encode"> + + <p>Type in the SAML Message below, and select which binding to use.</p> + + <form method="post" action="debug.php"> + <textarea style="width: 95%; border: 1px solid #999" cols="50" rows="20" name="decoded"><?php echo $this->data['decoded']; ?></textarea> + + <div style="margin: 1em"> + Use this binding: + <select name="binding"> + <option value="redirect">HTTP-REDIRECT</option> + <option value="post">HTTP-POST</option> + </select> + </div> + + <p><input type="submit" name="decode" value="« Encode SAML message" /></p> + </form> + +</div> <!-- #redirect --> + + + + +</div> <!-- #tabdiv --> + + + + + +<?php $this->includeAtTemplateBase('includes/footer.php'); ?> \ No newline at end of file diff --git a/modules/saml2debug/www/debug.php b/modules/saml2debug/www/debug.php new file mode 100644 index 0000000000000000000000000000000000000000..e976baaa96710df5bf420af172af94b56d68f7a0 --- /dev/null +++ b/modules/saml2debug/www/debug.php @@ -0,0 +1,68 @@ +<?php + +$config = SimpleSAML_Configuration::getInstance(); + + +function getValue($raw) { + + $val = $raw; + + $url = parse_url($raw, PHP_URL_QUERY); + if (!empty($url)) $val = $url; + + $arr = array(); + $query = parse_str($val, &$arr); + + #echo('<pre>');print_r($arr); + + if (array_key_exists('SAMLResponse', $arr)) return $arr['SAMLResponse']; + if (array_key_exists('SAMLRequest', $arr)) return $arr['SAMLRequest']; + if (array_key_exists('LogoutRequest', $arr)) return $arr['LogoutRequest']; + if (array_key_exists('LogoutResponse', $arr)) return $arr['LogoutResponse']; + + return urldecode(stripslashes($val)); +} + +function decode($raw) { + $message = getValue($raw); + #echo 'using value: ' . $message; exit; + + $base64decoded = base64_decode($message); + $gzinflated = gzinflate($base64decoded); + if ($gzinflated != FALSE) { + $base64decoded = $gzinflated; + } + $decoded = htmlentities($base64decoded); + return $decoded; +} + +function encode($message) { + if (!array_key_exists('binding', $_REQUEST)) throw new Exception('missing binding'); + if ($_REQUEST['binding'] === 'redirect') { + return urlencode(base64_encode(gzdeflate(stripslashes($message)))); + } else { + return urlencode(base64_encode(stripslashes($message))); + } +} + + +$decoded = '<html>'; +$encoded = 'fZJNT%2BMwEIbvSPwHy%2Fd8tMvHympSdUGISuwS0cCBm%2BtMUwfbk%2FU4zfLvSVMq2Euv45n3fd7xzOb%2FrGE78KTRZXwSp5yBU1hpV2f8ubyLfvJ5fn42I2lNKxZd2Lon%2BNsBBTZMOhLjQ8Y77wRK0iSctEAiKLFa%2FH4Q0zgVrceACg1ny9uMy7rCdaM2%2Bs0BWrtppK2UAdeoVjW2ruq1bevGImcvR6zpHmtJ1MHSUZAuDKU0vY7Si2h6VU5%2BiMuJuLx65az4dPql3SHBKaz1oYnEfVkWUfG4KkeBna7A%2Fxm6M14j1gZihZazBRH4MODcoKPOgl%2BB32kFz08PGd%2BG0JJIkr7v46%2BhRCaEpod17DCRivYZCkmkd4N28B3wfNyrGKP5bws9DS6PKDz%2FMpsl36Tyz%2F%2Fax1jeFmi0emcLY7C%2F8SDD0Z7dobcynHbbV3QVbcZW0TlqQemNhoqzJD%2B4%2Fn8Yw7l8AA%3D%3D'; + +$activeTab = 0; + +if (array_key_exists('encoded', $_REQUEST)) { + $decoded = decode($_REQUEST['encoded']); + $activeTab = 1; +} +if (array_key_exists('decoded', $_REQUEST)) { + $encoded = encode($_REQUEST['decoded']); +} + +$t = new SimpleSAML_XHTML_Template($config, 'saml2debug:debug.tpl.php'); +$t->data['encoded'] = $encoded; +$t->data['decoded'] = $decoded; +$t->data['activeTab'] = $activeTab; +$t->show(); + +?> \ No newline at end of file