ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
ilShibbolethRoleAssignmentRules Class Reference

Shibboleth role assignment rules. 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

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 25 of file class.ilShibbolethRoleAssignmentRules.php.

Member Function Documentation

◆ callPlugin()

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

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

References $DIC, and XapiProxy\$plugin.

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

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

◆ doAssignments()

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

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

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

Referenced by ilAuthProviderShibboleth\doAuthentication().

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

◆ getCountRules()

static ilShibbolethRoleAssignmentRules::getCountRules ( )
static

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

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

Referenced by ilAuthShibbolethSettingsGUI\parseRulesTable().

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

◆ updateAssignments()

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

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

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

Referenced by ilAuthProviderShibboleth\doAuthentication().

57  : bool
58  {
59  global $DIC;
60  $db = $DIC->database();
61  $rbac_admin = $DIC->rbac()->admin();
62  $rbac_review = $DIC->rbac()->review();
63  $logger = $DIC->logger()->root();
64  $query = "SELECT rule_id,add_on_update,remove_on_update FROM shib_role_assignment " . "WHERE add_on_update = 1 OR remove_on_update = 1";
65  $res = $db->query($query);
66  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
67  $rule = new ilShibbolethRoleAssignmentRule($row->rule_id);
68  // $matches = $rule->matches($a_data);
69  if ($row->add_on_update && $rule->doesMatch($a_data)) {
70  $logger->write(__METHOD__ . ': Assigned to role ' . ilObject::_lookupTitle($rule->getRoleId()));
71  $rbac_admin->assignUser($rule->getRoleId(), $a_usr_id);
72  }
73  if ($row->remove_on_update && !$rule->doesMatch($a_data)) {
74  $logger->write(__METHOD__ . ': Deassigned from role ' . ilObject::_lookupTitle($rule->getRoleId()));
75  $rbac_admin->deassignUser($rule->getRoleId(), $a_usr_id);
76  }
77  }
78  // check if is assigned to minimum one global role
79  if (!array_intersect($rbac_review->assignedRoles($a_usr_id), $rbac_review->getGlobalRoles())) {
80  $settings = new ilShibbolethSettings();
81  $default_role = $settings->getDefaultRole();
82  $logger->write(__METHOD__ . ': Assigned to default role ' . ilObject::_lookupTitle($default_role));
83  $rbac_admin->assignUser($default_role, $a_usr_id);
84  }
85 
86  return true;
87  }
$res
Definition: ltiservices.php:69
static _lookupTitle(int $obj_id)
global $DIC
Definition: shib_login.php:25
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ 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: