From 3bda880fe1c000c70ddf4dab23738c985ed66982 Mon Sep 17 00:00:00 2001 From: Olav Morken <olav.morken@uninett.no> Date: Tue, 16 Nov 2010 14:32:36 +0000 Subject: [PATCH] authmemcookie: Use the new compatibility class. git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@2650 44740490-163a-0410-bde0-09ae8108e29a --- www/authmemcookie.php | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/www/authmemcookie.php b/www/authmemcookie.php index 3b2729d92..b6b398fdf 100644 --- a/www/authmemcookie.php +++ b/www/authmemcookie.php @@ -15,7 +15,6 @@ require_once('_include.php'); try { /* Load simpleSAMLphp configuration. */ $globalConfig = SimpleSAML_Configuration::getInstance(); - $session = SimpleSAML_Session::getInstance(); /* Check if this module is enabled. */ if(!$globalConfig->getBoolean('enable.authmemcookie', FALSE)) { @@ -25,36 +24,27 @@ try { /* Load Auth MemCookie configuration. */ $amc = SimpleSAML_AuthMemCookie::getInstance(); - /* Check if the user is authorized. We attempt to authenticate the user if not. */ + /* Determine the method we should use to authenticate the user and retrieve the attributes. */ $loginMethod = $amc->getLoginMethod(); switch($loginMethod) { case 'authsource': /* The default now. */ $sourceId = $amc->getAuthSource(); $s = new SimpleSAML_Auth_Simple($sourceId); - $s->requireAuth(); break; case 'saml2': - if (!$session->isValid('saml2') ) { - SimpleSAML_Utilities::redirect( - '/' . $globalConfig->getBaseURL() . 'saml2/sp/initSSO.php', - array('RelayState' => SimpleSAML_Utilities::selfURL()) - ); - } + $s = new SimpleSAML_Auth_BWC('saml2/sp/initSSO.php', 'saml2'); break; case 'shib13': - if (!$session->isValid('shib13') ) { - SimpleSAML_Utilities::redirect( - '/' . $globalConfig->getBaseURL() . 'shib13/sp/initSSO.php', - array('RelayState' => SimpleSAML_Utilities::selfURL()) - ); - } + $s = new SimpleSAML_Auth_BWC('shib13/sp/initSSO.php', 'shib13'); break; default: /* Should never happen, as the login method is checked in the AuthMemCookie class. */ throw new Exception('Invalid login method.'); } + /* Check if the user is authorized. We attempt to authenticate the user if not. */ + $s->requireAuth(); /* Generate session id and save it in a cookie. */ $sessionID = SimpleSAML_Utilities::generateID(); @@ -67,7 +57,7 @@ try { /* Generate the authentication information. */ - $attributes = $session->getAttributes(); + $attributes = $s->getAttributes(); $authData = array(); @@ -111,10 +101,11 @@ try { $memcache = $amc->getMemcache(); - $expirationTime = $session->remainingTime(); + $expirationTime = $s->getAuthData('Expire'); $memcache->set($sessionID, $data, 0, $expirationTime); /* Register logout handler. */ + $session = SimpleSAML_Session::getInstance(); $session->registerLogoutHandler('SimpleSAML_AuthMemCookie', 'logoutHandler'); /* Redirect the user back to this page to signal that the login is completed. */ -- GitLab