ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Auth.php
Go to the documentation of this file.
1<?php
2namespace SimpleSAML\Utils;
3
5
11class 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
An exception for terminatinating execution or to throw for unit testing.
static getModuleURL($resource, array $parameters=array())
Get absolute URL to a specified module resource.
Definition: Module.php:220
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
static requireAdmin()
Require admin access to the current page.
Definition: Auth.php:60
static getById($authId, $type=null)
Retrieve authentication source.
Definition: Source.php:340
static getSessionFromRequest()
Retrieves the current session.
Definition: Session.php:241
$as
$session