ILIAS  release_8 Revision v8.24
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)
 

Static Protected Attributes

static array $active_plugins = []
 

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

119 : bool
120 {
121 global $DIC;
122 foreach ($DIC['component.factory']->getActivePluginsInSlot('shibhk') as $plugin) {
123 if ($plugin->checkRoleAssignment($a_plugin_id, $a_user_data)) {
124 return true;
125 }
126 }
127 return false;
128 }
global $DIC
Definition: feed.php:28

References $DIC, and XapiProxy\$plugin.

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

+ Here is the caller graph for this function:

◆ doAssignments()

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

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

91 : bool
92 {
93 global $DIC;
94 $ilDB = $DIC['ilDB'];
95 $rbacadmin = $DIC['rbacadmin'];
96 $ilLog = $DIC['ilLog'];
97 $query = "SELECT rule_id,add_on_update FROM shib_role_assignment WHERE add_on_update = 1";
98 $num_matches = 0;
99 $res = $ilDB->query($query);
100 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
101 $rule = new ilShibbolethRoleAssignmentRule($row->rule_id);
102 if ($rule->doesMatch($a_data)) {
103 $num_matches++;
104 $ilLog->write(__METHOD__ . ': Assigned to role ' . ilObject::_lookupTitle($rule->getRoleId()));
105 $rbacadmin->assignUser($rule->getRoleId(), $a_usr_id);
106 }
107 }
108 // Assign to default if no matching found
109 if ($num_matches === 0) {
111 $default_role = $settings->getDefaultRole();
112 $ilLog->write(__METHOD__ . ': Assigned to default role ' . ilObject::_lookupTitle($default_role));
113 $rbacadmin->assignUser($default_role, $a_usr_id);
114 }
115
116 return true;
117 }
static _lookupTitle(int $obj_id)
Class ilShibbolethSettings.
$res
Definition: ltiservices.php:69
array $settings
Setting values (LTI parameters, custom parameters and local parameters).
Definition: System.php:200
$query

References $DIC, $ilDB, $query, $res, ILIAS\LTI\ToolProvider\$settings, ilObject\_lookupTitle(), and ilDBConstants\FETCHMODE_OBJECT.

Referenced by ilAuthProviderShibboleth\doAuthentication().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCountRules()

static ilShibbolethRoleAssignmentRules::getCountRules ( )
static

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

49 : int
50 {
51 global $DIC;
52 $ilDB = $DIC['ilDB'];
53 $query = "SELECT COUNT(*) num FROM shib_role_assignment ";
54 $res = $ilDB->query($query);
55 $row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT);
56 return (int) ($row->num ?? 0);
57 }

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

Referenced by ilAuthShibbolethSettingsGUI\parseRulesTable().

+ Here is the caller graph for this function:

◆ updateAssignments()

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

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

59 : bool
60 {
61 global $DIC;
62 $ilDB = $DIC['ilDB'];
63 $rbacadmin = $DIC['rbacadmin'];
64 $rbacreview = $DIC['rbacreview'];
65 $ilLog = $DIC['ilLog'];
66 $query = "SELECT rule_id,add_on_update,remove_on_update FROM shib_role_assignment " . "WHERE add_on_update = 1 OR remove_on_update = 1";
67 $res = $ilDB->query($query);
68 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
69 $rule = new ilShibbolethRoleAssignmentRule($row->rule_id);
70 // $matches = $rule->matches($a_data);
71 if ($rule->doesMatch($a_data) && $row->add_on_update) {
72 $ilLog->write(__METHOD__ . ': Assigned to role ' . ilObject::_lookupTitle($rule->getRoleId()));
73 $rbacadmin->assignUser($rule->getRoleId(), $a_usr_id);
74 }
75 if (!$rule->doesMatch($a_data) && $row->remove_on_update) {
76 $ilLog->write(__METHOD__ . ': Deassigned from role ' . ilObject::_lookupTitle($rule->getRoleId()));
77 $rbacadmin->deassignUser($rule->getRoleId(), $a_usr_id);
78 }
79 }
80 // check if is assigned to minimum one global role
81 if (!array_intersect($rbacreview->assignedRoles($a_usr_id), $rbacreview->getGlobalRoles())) {
83 $default_role = $settings->getDefaultRole();
84 $ilLog->write(__METHOD__ . ': Assigned to default role ' . ilObject::_lookupTitle($default_role));
85 $rbacadmin->assignUser($default_role, $a_usr_id);
86 }
87
88 return true;
89 }

References $DIC, $ilDB, $query, $res, ILIAS\LTI\ToolProvider\$settings, ilObject\_lookupTitle(), and ilDBConstants\FETCHMODE_OBJECT.

Referenced by ilAuthProviderShibboleth\doAuthentication().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $active_plugins

array ilShibbolethRoleAssignmentRules::$active_plugins = []
staticprotected

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


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