ILIAS  trunk Revision v11.0_alpha-1749-g1a06bdef097
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilShibbolethRoleAssignmentRules Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Collaboration diagram for ilShibbolethRoleAssignmentRules:

Static Public Member Functions

static getCountRules ()
 
static updateAssignments (int $a_usr_id, array $a_data)
 
static doAssignments (int $a_usr_id, array $a_data)
 
static callPlugin (string $a_plugin_id, array $a_user_data)
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Shibboleth role assignment rules

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Fabian Schmid fabia.nosp@m.n.sc.nosp@m.hmid@.nosp@m.ilub.nosp@m..unib.nosp@m.e.ch
Version
$Id$

Definition at line 28 of file class.ilShibbolethRoleAssignmentRules.php.

Member Function Documentation

◆ callPlugin()

static ilShibbolethRoleAssignmentRules::callPlugin ( string  $a_plugin_id,
array  $a_user_data 
)
static

Definition at line 120 of file class.ilShibbolethRoleAssignmentRules.php.

References $DIC, and XapiProxy\$plugin.

Referenced by ilShibbolethRoleAssignmentRule\doesMatch(), and ilShibbolethRoleAssignmentRule\matches().

120  : bool
121  {
122  global $DIC;
123  foreach ($DIC['component.factory']->getActivePluginsInSlot('shibhk') as $plugin) {
124  if ($plugin->checkRoleAssignment($a_plugin_id, $a_user_data)) {
125  return true;
126  }
127  }
128  return false;
129  }
global $DIC
Definition: shib_login.php:22
+ Here is the caller graph for this function:

◆ doAssignments()

static ilShibbolethRoleAssignmentRules::doAssignments ( int  $a_usr_id,
array  $a_data 
)
static

Definition at line 92 of file class.ilShibbolethRoleAssignmentRules.php.

References $DIC, $res, ilObject\_lookupTitle(), and ilDBConstants\FETCHMODE_OBJECT.

Referenced by ilAuthProviderShibboleth\doAuthentication().

92  : bool
93  {
94  global $DIC;
95  $db = $DIC->database();
96  $rbac_admin = $DIC->rbac()->admin();
97  $logger = $DIC->logger()->root();
98  $query = "SELECT rule_id,add_on_update FROM shib_role_assignment WHERE add_on_update = 1";
99  $num_matches = 0;
100  $res = $db->query($query);
101  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
102  $rule = new ilShibbolethRoleAssignmentRule($row->rule_id);
103  if ($rule->doesMatch($a_data)) {
104  $num_matches++;
105  $logger->write(__METHOD__ . ': Assigned to role ' . ilObject::_lookupTitle($rule->getRoleId()));
106  $rbac_admin->assignUser($rule->getRoleId(), $a_usr_id);
107  }
108  }
109  // Assign to default if no matching found
110  if ($num_matches === 0) {
111  $settings = new ilShibbolethSettings();
112  $default_role = $settings->getDefaultRole();
113  $logger->write(__METHOD__ . ': Assigned to default role ' . ilObject::_lookupTitle($default_role));
114  $rbac_admin->assignUser($default_role, $a_usr_id);
115  }
116 
117  return true;
118  }
$res
Definition: ltiservices.php:66
static _lookupTitle(int $obj_id)
global $DIC
Definition: shib_login.php:22
Class ilShibbolethSettings.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCountRules()

static ilShibbolethRoleAssignmentRules::getCountRules ( )
static

Definition at line 50 of file class.ilShibbolethRoleAssignmentRules.php.

References $DIC, $res, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by ilAuthShibbolethSettingsGUI\parseRulesTable().

50  : int
51  {
52  global $DIC;
53  $db = $DIC->database();
54  $query = "SELECT COUNT(*) num FROM shib_role_assignment ";
55  $res = $db->query($query);
56  $row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT);
57  return (int) ($row->num ?? 0);
58  }
$res
Definition: ltiservices.php:66
global $DIC
Definition: shib_login.php:22
+ Here is the caller graph for this function:

◆ updateAssignments()

static ilShibbolethRoleAssignmentRules::updateAssignments ( int  $a_usr_id,
array  $a_data 
)
static

Definition at line 60 of file class.ilShibbolethRoleAssignmentRules.php.

References $DIC, $res, ilObject\_lookupTitle(), and ilDBConstants\FETCHMODE_OBJECT.

Referenced by ilAuthProviderShibboleth\doAuthentication().

60  : bool
61  {
62  global $DIC;
63  $db = $DIC->database();
64  $rbac_admin = $DIC->rbac()->admin();
65  $rbac_review = $DIC->rbac()->review();
66  $logger = $DIC->logger()->root();
67  $query = "SELECT rule_id,add_on_update,remove_on_update FROM shib_role_assignment " . "WHERE add_on_update = 1 OR remove_on_update = 1";
68  $res = $db->query($query);
69  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
70  $rule = new ilShibbolethRoleAssignmentRule($row->rule_id);
71  // $matches = $rule->matches($a_data);
72  if ($row->add_on_update && $rule->doesMatch($a_data)) {
73  $logger->write(__METHOD__ . ': Assigned to role ' . ilObject::_lookupTitle($rule->getRoleId()));
74  $rbac_admin->assignUser($rule->getRoleId(), $a_usr_id);
75  }
76  if ($row->remove_on_update && !$rule->doesMatch($a_data)) {
77  $logger->write(__METHOD__ . ': Deassigned from role ' . ilObject::_lookupTitle($rule->getRoleId()));
78  $rbac_admin->deassignUser($rule->getRoleId(), $a_usr_id);
79  }
80  }
81  // check if is assigned to minimum one global role
82  if (!array_intersect($rbac_review->assignedRoles($a_usr_id), $rbac_review->getGlobalRoles())) {
83  $settings = new ilShibbolethSettings();
84  $default_role = $settings->getDefaultRole();
85  $logger->write(__METHOD__ . ': Assigned to default role ' . ilObject::_lookupTitle($default_role));
86  $rbac_admin->assignUser($default_role, $a_usr_id);
87  }
88 
89  return true;
90  }
$res
Definition: ltiservices.php:66
static _lookupTitle(int $obj_id)
global $DIC
Definition: shib_login.php:22
Class ilShibbolethSettings.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

The documentation for this class was generated from the following file: