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

Thomas Graff: Patch to fallback to default value instead of showing error when...

Thomas Graff: Patch to fallback to default value instead of showing error when invalid boolean format set on ispassive or forceauthn

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@1487 44740490-163a-0410-bde0-09ae8108e29a
parent ae26e0d2
No related branches found
No related tags found
No related merge requests found
...@@ -138,13 +138,13 @@ class SimpleSAML_XML_SAML20_AuthnRequest { ...@@ -138,13 +138,13 @@ class SimpleSAML_XML_SAML20_AuthnRequest {
return FALSE; return FALSE;
} }
$fa = $root->getAttribute('IsPassive'); $ispas = $root->getAttribute('IsPassive');
if($fa === 'true') { try{
return TRUE; return $this->isSamlBoolTrue($ispas);
} elseif($fa === 'false') { }catch(Exception $e){
// ... I don't understand, default to false
return FALSE; return FALSE;
} else { // throw new Exception('Invalid value of IsPassive attribute in SAML2 AuthnRequest.');
throw new Exception('Invalid value of IsPassive attribute in SAML2 AuthnRequest.');
} }
} }
...@@ -168,12 +168,12 @@ class SimpleSAML_XML_SAML20_AuthnRequest { ...@@ -168,12 +168,12 @@ class SimpleSAML_XML_SAML20_AuthnRequest {
} }
$fa = $root->getAttribute('ForceAuthn'); $fa = $root->getAttribute('ForceAuthn');
if($fa === 'true') { try{
return TRUE; return $this->isSamlBoolTrue($fa);
} elseif($fa === 'false') { } catch(Exception $e){
// ... I don't understand, default to false
return FALSE; return FALSE;
} else { // throw new Exception('Invalid value of ForceAuthn attribute in SAML2 AuthnRequest.');
throw new Exception('Invalid value of ForceAuthn attribute in SAML2 AuthnRequest.');
} }
} }
...@@ -297,6 +297,25 @@ class SimpleSAML_XML_SAML20_AuthnRequest { ...@@ -297,6 +297,25 @@ class SimpleSAML_XML_SAML20_AuthnRequest {
public function getGeneratedID() { public function getGeneratedID() {
return $this->id; return $this->id;
} }
/**
* Check if a saml attribute value is a legal bool and if it is true or false.
* SAML legal bool values is true/false or 1/0.
*
* @throws Exception when no legal bool value is found
* @param string $boolSaml
* @return bool TRUE or FALSE
*/
private function isSamlBoolTrue($boolSaml){
if($boolSaml === 'true' || $boolSaml === '1') {
return TRUE;
} elseif($boolSaml === 'false' || $boolSaml === '0') {
return FALSE;
} else {
throw new Exception('Invalid bool value of attribute in SAML2 AuthnRequest.');
}
}
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment