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

statistics: Use SimpleSAML_Auth_Simple.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@2598 44740490-163a-0410-bde0-09ae8108e29a
parent 3423fe55
No related branches found
No related tags found
No related merge requests found
......@@ -15,7 +15,6 @@ class sspmod_statistics_AccessCheck {
* If the user doesn't have access, send the user to the login page.
*/
public static function checkAccess(SimpleSAML_Configuration $statconfig) {
$session = SimpleSAML_Session::getInstance();
$protected = $statconfig->getBoolean('protected', FALSE);
$authsource = $statconfig->getString('auth', NULL);
$allowedusers = $statconfig->getValue('allowedUsers', NULL);
......@@ -36,52 +35,50 @@ class sspmod_statistics_AccessCheck {
return;
}
if (isset($authsource) && $session->isValid($authsource) ) {
if (!isset($authsource)) {
// If authsource is not defined, init admin login.
SimpleSAML_Utilities::requireAdmin();
}
// User logged in with auth source.
SimpleSAML_Logger::debug('Statistics auth - valid login with auth source [' . $authsource . ']');
/* We are using an authsource for login. */
// Retrieving attributes
$attributes = $session->getAttributes();
$as = new SimpleSAML_Auth_Simple($authsource);
$as->requireAuth();
if (!empty($allowedusers)) {
// Check if userid exists
if (!isset($attributes[$useridattr][0]))
throw new Exception('User ID is missing');
// User logged in with auth source.
SimpleSAML_Logger::debug('Statistics auth - valid login with auth source [' . $authsource . ']');
// Check if userid is allowed access..
if (in_array($attributes[$useridattr][0], $allowedusers)) {
SimpleSAML_Logger::debug('Statistics auth - User granted access by user ID [' . $attributes[$useridattr][0] . ']');
return;
}
SimpleSAML_Logger::debug('Statistics auth - User denied access by user ID [' . $attributes[$useridattr][0] . ']');
// Retrieving attributes
$attributes = $as->getAttributes();
} else {
SimpleSAML_Logger::debug('Statistics auth - no allowedUsers list.');
}
if (!empty($allowedusers)) {
// Check if userid exists
if (!isset($attributes[$useridattr][0]))
throw new Exception('User ID is missing');
if (!is_null($acl)) {
$acl = new sspmod_core_ACL($acl);
if ($acl->allows($attributes)) {
SimpleSAML_Logger::debug('Statistics auth - allowed access by ACL.');
return;
}
SimpleSAML_Logger::debug('Statistics auth - denied access by ACL.');
} else {
SimpleSAML_Logger::debug('Statistics auth - no ACL configured.');
// Check if userid is allowed access..
if (in_array($attributes[$useridattr][0], $allowedusers)) {
SimpleSAML_Logger::debug('Statistics auth - User granted access by user ID [' . $attributes[$useridattr][0] . ']');
return;
}
SimpleSAML_Logger::debug('Statistics auth - User denied access by user ID [' . $attributes[$useridattr][0] . ']');
throw new SimpleSAML_Error_Exception('Access denied to the current user.');
} else {
SimpleSAML_Logger::debug('Statistics auth - no allowedUsers list.');
}
if(isset($authsource)) {
// If user is not logged in init login with authrouce if authsousrce is defined.
SimpleSAML_Auth_Default::initLogin($authsource, SimpleSAML_Utilities::selfURL());
if (!is_null($acl)) {
$acl = new sspmod_core_ACL($acl);
if ($acl->allows($attributes)) {
SimpleSAML_Logger::debug('Statistics auth - allowed access by ACL.');
return;
}
SimpleSAML_Logger::debug('Statistics auth - denied access by ACL.');
} else {
// If authsource is not defined, init admin login.
SimpleSAML_Utilities::requireAdmin();
SimpleSAML_Logger::debug('Statistics auth - no ACL configured.');
}
throw new SimpleSAML_Error_Exception('Access denied to the current user.');
}
}
\ No newline at end of file
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