ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
registry.php
Go to the documentation of this file.
1 <?php
2 
3 // Load SimpleSAMLphp, configuration and metadata
7 
9 
10 $authsource = "admin"; // force admin to authenticate as registry maintainer
11 $useridattr = $oauthconfig->getValue('useridattr', 'user');
12 
13 if ($session->isValid($authsource)) {
14  $attributes = $session->getAuthData($authsource, 'Attributes');
15  // Check if userid exists
16  if (!isset($attributes[$useridattr]))
17  throw new Exception('User ID is missing');
19 } else {
21  $as->initLogin(\SimpleSAML\Utils\HTTP::getSelfURL());
22 }
23 
24 function requireOwnership($entry, $userid) {
25  if (!isset($entry['owner']))
26  throw new Exception('OAuth Consumer has no owner. Which means no one is granted access, not even you.');
27  if ($entry['owner'] !== $userid)
28  throw new Exception('OAuth Consumer has an owner that is not equal to your userid, hence you are not granted access.');
29 }
30 
31 
32 if (isset($_REQUEST['delete'])) {
33  $entryc = $store->get('consumers', $_REQUEST['delete'], '');
34  $entry = $entryc['value'];
35 
36  requireOwnership($entry, $userid);
37  $store->remove('consumers', $entry['key'], '');
38 }
39 
40 
41 $list = $store->getList('consumers');
42 
43 $slist = array('mine' => array(), 'others' => array());
44 if (is_array($list))
45 foreach($list AS $listitem) {
46  if (array_key_exists('owner', $listitem['value'])) {
47  if ($listitem['value']['owner'] === $userid) {
48  $slist['mine'][] = $listitem; continue;
49  }
50  }
51  $slist['others'][] = $listitem;
52 }
53 
54 $template = new SimpleSAML_XHTML_Template($config, 'oauth:registry.list.php');
55 $template->data['entries'] = $slist;
56 $template->data['userid'] = $userid;
57 $template->show();
if(isset($_REQUEST['delete'])) $list
Definition: registry.php:41
$slist
Definition: registry.php:43
if(empty($userids)) $userid
$store
Definition: registry.php:8
if(is_array($list)) foreach($list AS $listitem) $template
Definition: registry.php:54
Attribute-related utility methods.
$as
$useridattr
Definition: registry.php:11
requireOwnership($entry, $userid)
Definition: registry.php:24
if(array_key_exists('yes', $_REQUEST)) $attributes
Definition: getconsent.php:85
$oauthconfig
Definition: registry.php:6
$authsource
Definition: registry.php:10
static getOptionalConfig($filename='config.php', $configSet='simplesaml')
Load a configuration file from a configuration set.
static getById($authId, $type=null)
Retrieve authentication source.
Definition: Source.php:340
$config
Definition: registry.php:4
$session
Definition: registry.php:5
static getSessionFromRequest()
Retrieves the current session.
Definition: Session.php:241
static getInstance($instancename='simplesaml')
Get a configuration file by its instance name.