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

www/saml2/sp: Use the new interface in Session.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@2642 44740490-163a-0410-bde0-09ae8108e29a
parent a7155085
No related branches found
No related tags found
No related merge requests found
...@@ -50,7 +50,7 @@ if (!$session->isValid('saml2') ) { ...@@ -50,7 +50,7 @@ if (!$session->isValid('saml2') ) {
/* Prepare attributes for presentation /* Prepare attributes for presentation
* and call a hook function for organizing the attribute array * and call a hook function for organizing the attribute array
*/ */
$attributes = $session->getAttributes(); $attributes = $session->getAuthData('saml2', 'Attributes');
$para = array( $para = array(
'attributes' => &$attributes 'attributes' => &$attributes
); );
...@@ -69,7 +69,7 @@ SimpleSAML_Module::callHooks('attributepresentation', $para); ...@@ -69,7 +69,7 @@ SimpleSAML_Module::callHooks('attributepresentation', $para);
$t = new SimpleSAML_XHTML_Template($config, 'status.php', 'attributes'); $t = new SimpleSAML_XHTML_Template($config, 'status.php', 'attributes');
$t->data['header'] = '{status:header_saml20_sp}'; $t->data['header'] = '{status:header_saml20_sp}';
$t->data['remaining'] = $session->remainingTime(); $t->data['remaining'] = $session->getAuthData('saml2', 'Expire') - time();
$t->data['sessionsize'] = $session->getSize(); $t->data['sessionsize'] = $session->getSize();
$t->data['attributes'] = $attributes; $t->data['attributes'] = $attributes;
$t->data['logouturl'] = '/' . $config->getBaseURL() . 'saml2/sp/initSLO.php?RelayState=/' . $t->data['logouturl'] = '/' . $config->getBaseURL() . 'saml2/sp/initSLO.php?RelayState=/' .
......
...@@ -37,14 +37,15 @@ function finishLogin($authProcState) { ...@@ -37,14 +37,15 @@ function finishLogin($authProcState) {
assert('array_key_exists("Source", $authProcState)'); assert('array_key_exists("Source", $authProcState)');
assert('array_key_exists("entityid", $authProcState["Source"])'); assert('array_key_exists("entityid", $authProcState["Source"])');
global $session; $authData = array(
'Attributes' => $authProcState['Attributes'],
'saml:sp:NameID' => $authProcState['core:saml20-sp:NameID'],
'saml:sp:SessionIndex' => $authProcState['core:saml20-sp:SessionIndex'],
'saml:sp:IdP' => $authProcState['Source']['entityid'],
);
/* Update the session information */ global $session;
$session->doLogin('saml2'); $session->doLogin('saml2', $authData);
$session->setAttributes($authProcState['Attributes']);
$session->setNameID($authProcState['core:saml20-sp:NameID']);
$session->setSessionIndex($authProcState['core:saml20-sp:SessionIndex']);
$session->setIdP($authProcState['Source']['entityid']);
SimpleSAML_Utilities::redirect($authProcState['core:saml20-sp:TargetURL']); SimpleSAML_Utilities::redirect($authProcState['core:saml20-sp:TargetURL']);
} }
......
...@@ -17,7 +17,7 @@ if (!$config->getBoolean('enable.saml20-sp', TRUE)) ...@@ -17,7 +17,7 @@ if (!$config->getBoolean('enable.saml20-sp', TRUE))
// Destroy local session if exists. // Destroy local session if exists.
$session->doLogout(); $session->doLogout('saml2');
$binding = SAML2_Binding::getCurrentBinding(); $binding = SAML2_Binding::getCurrentBinding();
$message = $binding->receive(); $message = $binding->receive();
......
...@@ -22,7 +22,7 @@ if (isset($_REQUEST['RelayState'])) { ...@@ -22,7 +22,7 @@ if (isset($_REQUEST['RelayState'])) {
try { try {
$metadata = SimpleSAML_Metadata_MetaDataStorageHandler::getMetadataHandler(); $metadata = SimpleSAML_Metadata_MetaDataStorageHandler::getMetadataHandler();
$idpEntityId = $session->getIdP(); $idpEntityId = $session->getAuthData('saml2', 'saml:sp:IdP');
if ($idpEntityId === NULL) { if ($idpEntityId === NULL) {
SimpleSAML_Logger::info('SAML2.0 - SP.initSLO: User not authenticated with an IdP.'); SimpleSAML_Logger::info('SAML2.0 - SP.initSLO: User not authenticated with an IdP.');
SimpleSAML_Utilities::redirect($returnTo); SimpleSAML_Utilities::redirect($returnTo);
...@@ -30,7 +30,7 @@ try { ...@@ -30,7 +30,7 @@ try {
$idpMetadata = $metadata->getMetaDataConfig($idpEntityId, 'saml20-idp-remote'); $idpMetadata = $metadata->getMetaDataConfig($idpEntityId, 'saml20-idp-remote');
$SLOendpoint = $idpMetadata->getDefaultEndpoint('SingleLogoutService', array(SAML2_Const::BINDING_HTTP_REDIRECT), NULL); $SLOendpoint = $idpMetadata->getDefaultEndpoint('SingleLogoutService', array(SAML2_Const::BINDING_HTTP_REDIRECT), NULL);
if ($SLOendpoint === NULL) { if ($SLOendpoint === NULL) {
$session->doLogout(); $session->doLogout('saml2');
SimpleSAML_Logger::info('SAML2.0 - SP.initSLO: No supported SingleLogoutService endpoint in IdP.'); SimpleSAML_Logger::info('SAML2.0 - SP.initSLO: No supported SingleLogoutService endpoint in IdP.');
SimpleSAML_Utilities::redirect($returnTo); SimpleSAML_Utilities::redirect($returnTo);
} }
...@@ -38,13 +38,13 @@ try { ...@@ -38,13 +38,13 @@ try {
$spEntityId = isset($_GET['spentityid']) ? $_GET['spentityid'] : $metadata->getMetaDataCurrentEntityID(); $spEntityId = isset($_GET['spentityid']) ? $_GET['spentityid'] : $metadata->getMetaDataCurrentEntityID();
$spMetadata = $metadata->getMetaDataConfig($spEntityId, 'saml20-sp-hosted'); $spMetadata = $metadata->getMetaDataConfig($spEntityId, 'saml20-sp-hosted');
$nameId = $session->getNameId(); $nameId = $session->getAuthData('saml2', 'saml:sp:NameID');
$lr = sspmod_saml_Message::buildLogoutRequest($spMetadata, $idpMetadata); $lr = sspmod_saml_Message::buildLogoutRequest($spMetadata, $idpMetadata);
$lr->setNameId($nameId); $lr->setNameId($nameId);
$lr->setSessionIndex($session->getSessionIndex()); $lr->setSessionIndex($session->getAuthData('saml2', 'saml:sp:SessionIndex'));
$session->doLogout(); $session->doLogout('saml2');
/* Save the $returnTo url until the user returns from the IdP. */ /* Save the $returnTo url until the user returns from the IdP. */
$session->setData('spLogoutReturnTo', $lr->getId(), $returnTo); $session->setData('spLogoutReturnTo', $lr->getId(), $returnTo);
......
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