Skip to content
Snippets Groups Projects
Commit 9cd5b0e4 authored by Olav Morken's avatar Olav Morken
Browse files

modules/saml2: Verify that the responding IdP is the same as the one we sent the message to.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@980 44740490-163a-0410-bde0-09ae8108e29a
parent 8a321bb5
No related branches found
No related tags found
No related merge requests found
...@@ -104,6 +104,28 @@ class sspmod_saml2_Auth_Source_SP extends SimpleSAML_Auth_Source { ...@@ -104,6 +104,28 @@ class sspmod_saml2_Auth_Source_SP extends SimpleSAML_Auth_Source {
return $this->entityId; return $this->entityId;
} }
/**
* Check if the IdP entity id is allowed to authenticate users for this authentication source.
*
* @param string $idpEntityId The entity id of the IdP.
* @return boolean TRUE if it is valid, FALSE if not.
*/
public function isIdPValid($idpEntityId) {
assert('is_string($idpEntityId)');
if ($this->idp === NULL) {
/* No IdP configured - all are allowed. */
return TRUE;
}
if ($this->idp === $idpEntityId) {
return TRUE;
}
return FALSE;
}
} }
?> ?>
\ No newline at end of file
...@@ -41,7 +41,11 @@ if($result === FALSE) { ...@@ -41,7 +41,11 @@ if($result === FALSE) {
/* The response should include the entity id of the IdP. */ /* The response should include the entity id of the IdP. */
$idp = $authnResponse->getIssuer(); $idp = $authnResponse->getIssuer();
/* TODO: Check that IdP is the correct IdP. */ /* Check if the IdP is allowed to authenticate users for this authentication source. */
if (!$source->isIdPValid($idp)) {
throw new Exception('Invalid IdP responded for authentication source with id ' . $sourceId .
'. The IdP was ' . var_export($idp, TRUE));
}
/* TODO: Save NameID & SessionIndex for logout. */ /* TODO: Save NameID & SessionIndex for logout. */
......
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