ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilShibbolethRoleAssignmentRules Class Reference

Shibboleth role assignment rules. More...

+ Collaboration diagram for ilShibbolethRoleAssignmentRules:

Static Public Member Functions

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

Static Protected Attributes

static $active_plugins = NULL
 

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

Member Function Documentation

◆ callPlugin()

static ilShibbolethRoleAssignmentRules::callPlugin (   $a_plugin_id,
  $a_user_data 
)
static
Parameters
$a_plugin_id
$a_user_data
Returns
bool

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

References $DIC, $ok, and IL_COMP_SERVICE.

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

152  {
153  global $DIC;
154  $ilPluginAdmin = $DIC['ilPluginAdmin'];
155  if (self::$active_plugins == NULL) {
156  self::$active_plugins = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_SERVICE, 'AuthShibboleth', 'shibhk');
157  }
158  $assigned = false;
159  foreach (self::$active_plugins as $plugin_name) {
160  $ok = false;
161  $plugin_obj = $ilPluginAdmin->getPluginObject(IL_COMP_SERVICE, 'AuthShibboleth', 'shibhk', $plugin_name);
162  if ($plugin_obj instanceof ilShibbolethRoleAssignmentPlugin) {
163  $ok = $plugin_obj->checkRoleAssignment($a_plugin_id, $a_user_data);
164  }
165  if ($ok) {
166  $assigned = true;
167  }
168  }
169 
170  return $assigned;
171  }
Interface for shibboleth role assignment plugins.
global $DIC
const IL_COMP_SERVICE
+ Here is the caller graph for this function:

◆ doAssignments()

static ilShibbolethRoleAssignmentRules::doAssignments (   $a_usr_id,
  $a_data 
)
static
Parameters
$a_usr_id
$a_data
Returns
bool

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

References $DIC, $ilDB, $ilLog, $query, $res, $row, ilObject\_lookupTitle(), ilDBConstants\FETCHMODE_OBJECT, and shibConfig\getInstance().

Referenced by ilAuthProviderShibboleth\doAuthentication(), and ShibAuth\login().

119  {
120  global $DIC;
121  $ilDB = $DIC['ilDB'];
122  $rbacadmin = $DIC['rbacadmin'];
123  $ilLog = $DIC['ilLog'];
124  $query = "SELECT rule_id,add_on_update FROM shib_role_assignment WHERE add_on_update = 1";
125  $num_matches = 0;
126  $res = $ilDB->query($query);
127  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
128  $rule = new ilShibbolethRoleAssignmentRule($row->rule_id);
129  if ($rule->doesMatch($a_data)) {
130  $num_matches ++;
131  $ilLog->write(__METHOD__ . ': Assigned to role ' . ilObject::_lookupTitle($rule->getRoleId()));
132  $rbacadmin->assignUser($rule->getRoleId(), $a_usr_id);
133  }
134  }
135  // Assign to default if no matching found
136  if (! $num_matches) {
137  $default_role = shibConfig::getInstance()->getUserDefaultRole();
138  $ilLog->write(__METHOD__ . ': Assigned to default role ' . ilObject::_lookupTitle($default_role));
139  $rbacadmin->assignUser($default_role, $a_usr_id);
140  }
141 
142  return true;
143  }
static _lookupTitle($a_id)
lookup object title
static getInstance()
global $ilDB
global $DIC
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCountRules()

static ilShibbolethRoleAssignmentRules::getCountRules ( )
static

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

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

Referenced by ilAuthShibbolethSettingsGUI\parseRulesTable(), and ilAuthShibbolethSettingsGUI\setSubTabs().

61  {
62  global $DIC;
63  $ilDB = $DIC['ilDB'];
64  $query = "SELECT COUNT(*) num FROM shib_role_assignment ";
65  $res = $ilDB->query($query);
66  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
67  return $row->num;
68  }
69 
70  return 0;
71  }
global $ilDB
global $DIC
+ Here is the caller graph for this function:

◆ updateAssignments()

static ilShibbolethRoleAssignmentRules::updateAssignments (   $a_usr_id,
  $a_data 
)
static
Parameters
$a_usr_id
$a_data
Returns
bool

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

References $DIC, $ilDB, $ilLog, $query, $res, $row, ilObject\_lookupTitle(), ilDBConstants\FETCHMODE_OBJECT, and shibConfig\getInstance().

Referenced by ilAuthProviderShibboleth\doAuthentication(), and ShibAuth\login().

80  {
81  require_once('./Services/AuthShibboleth/classes/Config/class.shibConfig.php');
82 
83  global $DIC;
84  $ilDB = $DIC['ilDB'];
85  $rbacadmin = $DIC['rbacadmin'];
86  $rbacreview = $DIC['rbacreview'];
87  $ilLog = $DIC['ilLog'];
88  $query = "SELECT rule_id,add_on_update,remove_on_update FROM shib_role_assignment " . "WHERE add_on_update = 1 OR remove_on_update = 1";
89  $res = $ilDB->query($query);
90  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
91  $rule = new ilShibbolethRoleAssignmentRule($row->rule_id);
92  // $matches = $rule->matches($a_data);
93  if ($rule->doesMatch($a_data) and $row->add_on_update) {
94  $ilLog->write(__METHOD__ . ': Assigned to role ' . ilObject::_lookupTitle($rule->getRoleId()));
95  $rbacadmin->assignUser($rule->getRoleId(), $a_usr_id);
96  }
97  if (! $rule->doesMatch($a_data) and $row->remove_on_update) {
98  $ilLog->write(__METHOD__ . ': Deassigned from role ' . ilObject::_lookupTitle($rule->getRoleId()));
99  $rbacadmin->deassignUser($rule->getRoleId(), $a_usr_id);
100  }
101  }
102  // check if is assigned to minimum one global role
103  if (! array_intersect($rbacreview->assignedRoles($a_usr_id), $rbacreview->getGlobalRoles())) {
104  $default_role = shibConfig::getInstance()->getUserDefaultRole();
105  $ilLog->write(__METHOD__ . ': Assigned to default role ' . ilObject::_lookupTitle($default_role));
106  $rbacadmin->assignUser($default_role, $a_usr_id);
107  }
108 
109  return true;
110  }
static _lookupTitle($a_id)
lookup object title
static getInstance()
global $ilDB
global $DIC
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $active_plugins

ilShibbolethRoleAssignmentRules::$active_plugins = NULL
staticprotected

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


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