ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
Auth.php
Go to the documentation of this file.
1 <?php
2 namespace SimpleSAML\Utils;
3 
5 
11 class Auth
12 {
13 
22  public static function getAdminLoginURL($returnTo = null)
23  {
24  if (!(is_string($returnTo) || is_null($returnTo))) {
25  throw new \InvalidArgumentException('Invalid input parameters.');
26  }
27 
28  if ($returnTo === null) {
29  $returnTo = HTTP::getSelfURL();
30  }
31 
32  return Module::getModuleURL('core/login-admin.php', array('ReturnTo' => $returnTo));
33  }
34 
42  public static function isAdmin()
43  {
45  return $session->isValid('admin') || $session->isValid('login-admin');
46  }
47 
60  public static function requireAdmin()
61  {
62  if (self::isAdmin()) {
63  return;
64  }
65 
66  // not authenticated as admin user, start authentication
67  if (\SimpleSAML_Auth_Source::getById('admin') !== null) {
68  $as = new \SimpleSAML\Auth\Simple('admin');
69  $as->login();
70  } else {
71  throw new \SimpleSAML_Error_Exception(
72  'Cannot find "admin" auth source, and admin privileges are required.'
73  );
74  }
75  }
76 }
if(!isset($_REQUEST['ReturnTo'])) $returnTo
Definition: authpage.php:16
static requireAdmin()
Require admin access to the current page.
Definition: Auth.php:60
static isAdmin()
Check whether the current user is admin.
Definition: Auth.php:42
static getAdminLoginURL($returnTo=null)
Retrieve a admin login URL.
Definition: Auth.php:22
$session
static getModuleURL($resource, array $parameters=array())
Get absolute URL to a specified module resource.
Definition: Module.php:303
$as
Create styles array
The data for the language used.
static getById($authId, $type=null)
Retrieve authentication source.
Definition: Source.php:324
static getSessionFromRequest()
Retrieves the current session.
Definition: Session.php:243