From 06a06f751e7bf43dc42b8e8802133cfadb3e076e Mon Sep 17 00:00:00 2001 From: Olav Morken <olav.morken@uninett.no> Date: Mon, 25 Oct 2010 12:27:55 +0000 Subject: [PATCH] oauth: Change to use SimpleSAML_Auth_Simple. git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@2600 44740490-163a-0410-bde0-09ae8108e29a --- modules/oauth/www/authorize.php | 8 +++----- modules/oauth/www/registry.edit.php | 17 +++++++---------- modules/oauth/www/registry.php | 17 +++++++---------- 3 files changed, 17 insertions(+), 25 deletions(-) diff --git a/modules/oauth/www/authorize.php b/modules/oauth/www/authorize.php index e0a9bb0f2..3b700f61f 100644 --- a/modules/oauth/www/authorize.php +++ b/modules/oauth/www/authorize.php @@ -25,11 +25,9 @@ $config = SimpleSAML_Configuration::getInstance(); $session = SimpleSAML_Session::getInstance(); $as = $oauthconfig->getString('auth'); -if (!$session->isValid($as)) { - SimpleSAML_Auth_Default::initLogin($as, SimpleSAML_Utilities::selfURL()); -} - -$attributes = $session->getAttributes(); +$as = new SimpleSAML_Auth_Simple($as); +$as->requireAuth(); +$attributes = $as->getAttributes(); #print_r($attributes); diff --git a/modules/oauth/www/registry.edit.php b/modules/oauth/www/registry.edit.php index b0283198d..ed6a835aa 100644 --- a/modules/oauth/www/registry.edit.php +++ b/modules/oauth/www/registry.edit.php @@ -2,7 +2,6 @@ /* Load simpleSAMLphp, configuration and metadata */ $config = SimpleSAML_Configuration::getInstance(); -$session = SimpleSAML_Session::getInstance(); $oauthconfig = SimpleSAML_Configuration::getOptionalConfig('module_oauth.php'); $store = new sspmod_core_Storage_SQLPermanentStorage('oauth'); @@ -10,15 +9,13 @@ $store = new sspmod_core_Storage_SQLPermanentStorage('oauth'); $authsource = $oauthconfig->getValue('auth', 'admin'); $useridattr = $oauthconfig->getValue('useridattr', 'user'); -if ($session->isValid($authsource)) { - $attributes = $session->getAttributes(); - // Check if userid exists - if (!isset($attributes[$useridattr])) - throw new Exception('User ID is missing'); - $userid = $attributes[$useridattr][0]; -} else { - SimpleSAML_Auth_Default::initLogin($authsource, SimpleSAML_Utilities::selfURL()); -} +$as = new SimpleSAML_Auth_Simple($authsource); +$as->requireAuth(); +$attributes = $as->getAttributes(); +// Check if userid exists +if (!isset($attributes[$useridattr])) + throw new Exception('User ID is missing'); +$userid = $attributes[$useridattr][0]; function requireOwnership($entry, $userid) { if (!isset($entry['owner'])) diff --git a/modules/oauth/www/registry.php b/modules/oauth/www/registry.php index 51bd0e8a2..31c32166a 100644 --- a/modules/oauth/www/registry.php +++ b/modules/oauth/www/registry.php @@ -2,7 +2,6 @@ /* Load simpleSAMLphp, configuration and metadata */ $config = SimpleSAML_Configuration::getInstance(); -$session = SimpleSAML_Session::getInstance(); $oauthconfig = SimpleSAML_Configuration::getOptionalConfig('module_oauth.php'); $store = new sspmod_core_Storage_SQLPermanentStorage('oauth'); @@ -10,15 +9,13 @@ $store = new sspmod_core_Storage_SQLPermanentStorage('oauth'); $authsource = $oauthconfig->getValue('auth', 'admin'); $useridattr = $oauthconfig->getValue('useridattr', 'user'); -if ($session->isValid($authsource)) { - $attributes = $session->getAttributes(); - // Check if userid exists - if (!isset($attributes[$useridattr])) - throw new Exception('User ID is missing'); - $userid = $attributes[$useridattr][0]; -} else { - SimpleSAML_Auth_Default::initLogin($authsource, SimpleSAML_Utilities::selfURL()); -} +$as = new SimpleSAML_Auth_Simple($authsource); +$as->requireAuth(); +$attributes = $as->getAttributes(); +// Check if userid exists +if (!isset($attributes[$useridattr])) + throw new Exception('User ID is missing'); +$userid = $attributes[$useridattr][0]; function requireOwnership($entry, $userid) { if (!isset($entry['owner'])) -- GitLab