Skip to content
Snippets Groups Projects
Commit 40f4b1cd authored by Andreas Åkre Solberg's avatar Andreas Åkre Solberg
Browse files

Improved error handling when parsing authentication requests

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@384 44740490-163a-0410-bde0-09ae8108e29a
parent 4adcc2ef
No related branches found
No related tags found
No related merge requests found
...@@ -32,6 +32,11 @@ class SimpleSAML_Bindings_SAML20_HTTPRedirect { ...@@ -32,6 +32,11 @@ class SimpleSAML_Bindings_SAML20_HTTPRedirect {
return $query; return $query;
} }
if (!array_key_exists('privatekey', $md)) {
throw new Exception('If you set request.signing to be true in the metadata, you also have to add the privatekey parameter.');
}
/* Load the private key. */ /* Load the private key. */
$privatekey = $this->configuration->getPathValue('certdir') . $md['privatekey']; $privatekey = $this->configuration->getPathValue('certdir') . $md['privatekey'];
...@@ -198,19 +203,26 @@ class SimpleSAML_Bindings_SAML20_HTTPRedirect { ...@@ -198,19 +203,26 @@ class SimpleSAML_Bindings_SAML20_HTTPRedirect {
$relaystate = $get['RelayState']; $relaystate = $get['RelayState'];
} else { } else {
$relaystate = NULL; $relaystate = NULL;
}
$decodedRequest = @base64_decode($rawRequest, TRUE);
if (!$decodedRequest) {
throw new Exception('Could not base64 decode SAMLRequest GET parameter');
}
$samlRequestXML = @gzinflate($decodedRequest);
if (!$samlRequestXML) {
$error = error_get_last();
throw new Exception('Could not gzinflate base64 decoded SAMLRequest: ' . $error['message'] );
} }
$samlRequestXML = gzinflate(base64_decode( $rawRequest ));
$samlRequest = new SimpleSAML_XML_SAML20_AuthnRequest($this->configuration, $this->metadata); $samlRequest = new SimpleSAML_XML_SAML20_AuthnRequest($this->configuration, $this->metadata);
$samlRequest->setXML($samlRequestXML); $samlRequest->setXML($samlRequestXML);
if (isset($relaystate)) { if (!is_null($relaystate)) {
$samlRequest->setRelayState($relaystate); $samlRequest->setRelayState($relaystate);
} }
#echo("Authn response = " . $samlResponse );
return $samlRequest; return $samlRequest;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment