ILIAS  trunk Revision v12.0_alpha-1221-g4e438232683
ilAuthProviderLTI Class Reference

OAuth based lti authentication. More...

+ Inheritance diagram for ilAuthProviderLTI:
+ Collaboration diagram for ilAuthProviderLTI:

Public Member Functions

 __construct (ilAuthCredentials $credentials)
 Constructor. More...
 
- Public Member Functions inherited from ilAuthProvider
 __construct (ilAuthCredentials $credentials)
 
 getLogger ()
 
 getCredentials ()
 
- Public Member Functions inherited from ilAuthProviderInterface
 doAuthentication (ilAuthStatus $status)
 

Static Public Member Functions

static getAuthModeByKey (string $a_auth_key)
 Get auth mode by key. More...
 
static getKeyByAuthMode (string $a_auth_mode)
 Get auth id by auth mode. More...
 
static getActiveAuthModes ()
 get all active authmode server ids More...
 
static getAuthModes ()
 
static lookupConsumer (int $a_sid)
 Lookup consumer title. More...
 
static getServerIdByAuthMode (string $a_auth_mode)
 Get auth id by auth mode. More...
 
static isAuthModeLTI (string $a_auth_mode)
 Check if user auth mode is LTI. More...
 

Data Fields

const AUTH_MODE_PREFIX = 'lti'
 

Protected Member Functions

 findAuthKeyId (string $a_oauth_consumer_key)
 find consumer key id More...
 
 findAuthPrefix (int $a_lti_id)
 find lti id More...
 
 findGlobalRole (int $a_lti_id)
 find global role of consumer More...
 
 findUserId (string $a_oauth_user, string $a_oauth_id, string $a_user_prefix)
 Find user by auth mode and lti id. More...
 
 updateUser (int $a_local_user_id, ilLTIPlatform $consumer)
 update existing user @access protected More...
 
 createUser (ilLTIPlatform $consumer)
 create new user @access protected More...
 
 handleLocalRoleAssignments (int $user_id, ilLTIPlatform $consumer, int $target_ref_id, ?int $default_rol_id=null)
 
 mapLTIRoleToLocalRole (string $lti_role, ilLTIProviderObjectSetting $settings)
 Maps an LTI role (URI or simple name) to a local ILIAS role ID. More...
 
- Protected Member Functions inherited from ilAuthProvider
 handleAuthenticationFail (ilAuthStatus $status, string $a_reason)
 

Protected Attributes

string $launchReturnUrl = ""
 

Private Attributes

ilLTIDataConnector $dataConnector = null
 
string $lti_context_id = ""
 
int $ref_id = 0
 
ilLTITool $provider = null
 
array $messageParameters = null
 
ilLogger $logger = null
 

Detailed Description

OAuth based lti authentication.

Author
Stefan Meyer smeye.nosp@m.r.il.nosp@m.ias@g.nosp@m.mx.d.nosp@m.e
Uwe Kohnle kohnl.nosp@m.e@in.nosp@m.terne.nosp@m.tleh.nosp@m.rer-g.nosp@m.mbh..nosp@m.de
Stefan Schneider

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

Constructor & Destructor Documentation

◆ __construct()

ilAuthProviderLTI::__construct ( ilAuthCredentials  $credentials)

Constructor.

Reimplemented from ilAuthProvider.

Definition at line 43 of file class.ilAuthProviderLTI.php.

44 {
46 $this->logger = ilLoggerFactory::getLogger('ltis');
47 }
ilAuthCredentials $credentials
static getLogger(string $a_component_id)
Get component logger.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

References ilAuthProvider\$credentials, ILIAS\GlobalScreen\Provider\__construct(), ilLoggerFactory\getLogger(), and ILIAS\Repository\logger().

+ Here is the call graph for this function:

Member Function Documentation

◆ createUser()

ilAuthProviderLTI::createUser ( ilLTIPlatform  $consumer)
protected

create new user @access protected

Parameters
ilLTIPlatform$consumer
Returns
int
Exceptions
ilPasswordException
ilUserException

Definition at line 427 of file class.ilAuthProviderLTI.php.

427 : int
428 {
429 global $ilClientIniFile, $DIC;
430 // if (empty($this->messageParameters)) {
431 // $status->setReason('empty_lti_message_parameters');
432 // $status->setStatus(ilAuthStatus::STATUS_AUTHENTICATION_FAILED);
433 // return false;
434 // }
435 $userObj = new ilObjUser();
436 $local_user = ilAuthUtils::_generateLogin($consumer->getPrefix() . '_' . $this->getCredentials()->getUsername());
437
438 $newUser["login"] = $local_user;
439 if (isset($this->messageParameters['lis_person_name_given'])) {
440 $newUser["firstname"] = $this->messageParameters['lis_person_name_given'];
441 } else {
442 $newUser["firstname"] = '-';
443 }
444 if (isset($this->messageParameters['lis_person_name_family'])) {
445 $newUser["lastname"] = $this->messageParameters['lis_person_name_family'];
446 } else {
447 $newUser["lastname"] = '-';
448 }
449 $newUser['email'] = $this->messageParameters['lis_person_contact_email_primary'];
450
451 // set "plain md5" password (= no valid password)
452 // $newUser["passwd"] = "";
453 $newUser["passwd_type"] = ilObjUser::PASSWD_CRYPTED;
454
455 $newUser["auth_mode"] = 'lti_' . $consumer->getExtConsumerId();
456 $newUser['ext_account'] = $this->getCredentials()->getUsername();
457 $newUser["profile_incomplete"] = 0;
458
459 // ILIAS 8
460 //check
461 $newUser["gender"] = 'n';
462 $newUser["title"] = null;
463 $newUser["birthday"] = null;
464 $newUser["institution"] = null;
465 $newUser["department"] = null;
466 $newUser["street"] = null;
467 $newUser["city"] = null;
468 $newUser["zipcode"] = null;
469 $newUser["country"] = null;
470 $newUser["sel_country"] = null;
471 $newUser["phone_office"] = null;
472 $newUser["phone_home"] = null;
473 $newUser["phone_mobile"] = null;
474 $newUser["fax"] = null;
475 $newUser["matriculation"] = null;
476 $newUser["second_email"] = null;
477 $newUser["hobby"] = null;
478 $newUser["client_ip"] = null;
479 $newUser["passwd_salt"] = null;//$newUser->getPasswordSalt();
480 $newUser["latitude"] = null;
481 $newUser["longitude"] = null;
482 $newUser["loc_zoom"] = null;
483 $newUser["last_login"] = null;
484 $newUser["first_login"] = null;
485 $newUser["last_profile_prompt"] = null;
486 $newUser["last_update"] = ilUtil::now();
487 $newUser["create_date"] = ilUtil::now();
488 $newUser["referral_comment"] = null;
489 $newUser["approve_date"] = null;
490 $newUser["agree_date"] = null;
491 $newUser["inactivation_date"] = null;
492 $newUser["time_limit_from"] = null;
493 $newUser["time_limit_until"] = null;
494 $newUser["is_self_registered"] = null;
495 //end to check
496
497 $newUser["passwd_enc_type"] = "";
498 $newUser["active"] = true;
499 $newUser["time_limit_owner"] = 7;
500 $newUser["time_limit_unlimited"] = 0;
501 $newUser["time_limit_message"] = 0;
502 $newUser["passwd"] = " ";
503 // $newUser["last_update"]
504
505 // system data
506 $userObj->assignData($newUser);
507 $userObj->setTitle($userObj->getFullname());
508 $userObj->setDescription($userObj->getEmail());
509
510 // set user language
511 $userObj->setLanguage($consumer->getLanguage());
512
513 // Time limit
514 $userObj->setTimeLimitOwner(7);
515 $userObj->setTimeLimitUnlimited(false);
516 $userObj->setTimeLimitFrom(time() - 5);
517 // todo ?
518 $userObj->setTimeLimitUntil(time() + (int) $ilClientIniFile->readVariable("session", "expire"));
519
520 // Create user in DB
521 $userObj->setOwner(6);
522 $userObj->create();
523 $userObj->setActive(true);
524 // $userObj->updateOwner();
525 $userObj->setLastPasswordChangeTS(time());
526 $userObj->saveAsNew();
527 $userObj->writePrefs();
528
529 $GLOBALS['DIC']->rbac()->admin()->assignUser($consumer->getRole(), $userObj->getId());
530
531 $this->getLogger()->info('Created new lti user with uid: ' . $userObj->getId() . ' and login: ' . $userObj->getLogin());
532 return $userObj->getId();
533 }
static _generateLogin(string $a_login)
generate free login by starting with a default string and adding postfix numbers
User class.
const PASSWD_CRYPTED
static now()
Return current timestamp in Y-m-d H:i:s format.
global $DIC
Definition: shib_login.php:26
$GLOBALS["DIC"]
Definition: wac.php:54

References $DIC, $GLOBALS, ilAuthUtils\_generateLogin(), ilAuthProvider\getCredentials(), ilLTIPlatform\getExtConsumerId(), ilLTIPlatform\getLanguage(), ilAuthProvider\getLogger(), ilLTIPlatform\getPrefix(), ilLTIPlatform\getRole(), ilUtil\now(), and ilObjUser\PASSWD_CRYPTED.

+ Here is the call graph for this function:

◆ findAuthKeyId()

ilAuthProviderLTI::findAuthKeyId ( string  $a_oauth_consumer_key)
protected

find consumer key id

Parameters
string$a_oauth_consumer_key
Returns
int

Definition at line 163 of file class.ilAuthProviderLTI.php.

163 : int
164 {
165 global $ilDB;
166
167 $query = 'SELECT consumer_pk from lti2_consumer where consumer_key = ' . $ilDB->quote(
168 $a_oauth_consumer_key,
169 'text'
170 );
171 // $query = 'SELECT id from lti_ext_consumer where consumer_key = '.$ilDB->quote($a_oauth_consumer_key,'text');
172 $this->getLogger()->debug($query);
173 $res = $ilDB->query($query);
174
175 $lti_id = 0;
176 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
177 $lti_id = $row->consumer_pk;
178 // $lti_id = $row->id;
179 }
180 $this->getLogger()->debug('External consumer key is: ' . (int) $lti_id);
181 return $lti_id;
182 }
const FETCHMODE_OBJECT
$res
Definition: ltiservices.php:69

References $ilDB, $res, ilDBConstants\FETCHMODE_OBJECT, and ilAuthProvider\getLogger().

+ Here is the call graph for this function:

◆ findAuthPrefix()

ilAuthProviderLTI::findAuthPrefix ( int  $a_lti_id)
protected

find lti id

Parameters
int$a_lti_id
Returns
string

Definition at line 189 of file class.ilAuthProviderLTI.php.

189 : string
190 {
191 global $ilDB;
192
193 $query = 'SELECT prefix from lti_ext_consumer where id = ' . $ilDB->quote($a_lti_id, 'integer');
194 $this->getLogger()->debug($query);
195 $res = $ilDB->query($query);
196
197 // $prefix = 'lti'.$a_lti_id.'_';
198 $prefix = '';
199 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
200 $prefix = $row->prefix;
201 }
202 $this->getLogger()->debug('LTI prefix: ' . $prefix);
203 return $prefix;
204 }

References $ilDB, $res, ilDBConstants\FETCHMODE_OBJECT, and ilAuthProvider\getLogger().

+ Here is the call graph for this function:

◆ findGlobalRole()

ilAuthProviderLTI::findGlobalRole ( int  $a_lti_id)
protected

find global role of consumer

Parameters
int$a_lti_id
Returns
int|null

Definition at line 211 of file class.ilAuthProviderLTI.php.

211 : ?int
212 {
213 global $ilDB;
214
215 $query = 'SELECT role from lti_ext_consumer where id = ' . $ilDB->quote($a_lti_id, 'integer');
216 $this->getLogger()->debug($query);
217 $res = $ilDB->query($query);
218
219 $role = null;
220 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
221 $role = (int) $row->role;
222 }
223 $this->getLogger()->debug('LTI role: ' . $role);
224 return $role;
225 }

References $ilDB, $res, ilDBConstants\FETCHMODE_OBJECT, ilAuthProvider\getLogger(), and ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ findUserId()

ilAuthProviderLTI::findUserId ( string  $a_oauth_user,
string  $a_oauth_id,
string  $a_user_prefix 
)
protected

Find user by auth mode and lti id.

Parameters
string$a_oauth_user
string$a_oauth_id
string$a_user_prefix
Returns
int

Definition at line 359 of file class.ilAuthProviderLTI.php.

359 : int
360 {
362 self::AUTH_MODE_PREFIX . '_' . $a_oauth_id,
363 $a_oauth_user
364 );
365 $user_id = 0;
366 if ($user_name) {
367 $user_id = ilObjUser::_lookupId($user_name);
368 }
369 $this->getLogger()->debug('Found user with auth mode lti_' . $a_oauth_id . ' with user_id: ' . $user_id);
370 return $user_id;
371 }
static _lookupId(string|array $a_user_str)
static _checkExternalAuthAccount(string $a_auth, string $a_account, bool $tryFallback=true)
check whether external account and authentication method matches with a user

References $user_id, ilObjUser\_checkExternalAuthAccount(), ilObjUser\_lookupId(), and ilAuthProvider\getLogger().

+ Here is the call graph for this function:

◆ getActiveAuthModes()

static ilAuthProviderLTI::getActiveAuthModes ( )
static

get all active authmode server ids

Returns
array

Definition at line 81 of file class.ilAuthProviderLTI.php.

81 : array
82 {
83 global $ilDB;
84
85 // move to connector
86 $query = 'SELECT consumer_pk from lti2_consumer where enabled = ' . $ilDB->quote(1, 'integer');
87 $res = $ilDB->query($query);
88
89 $sids = array();
90 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
91 $sids[] = $row->consumer_pk;
92 }
93 return $sids;
94 }

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

Referenced by ilAuthUtils\_isExternalAccountEnabled().

+ Here is the caller graph for this function:

◆ getAuthModeByKey()

static ilAuthProviderLTI::getAuthModeByKey ( string  $a_auth_key)
static

Get auth mode by key.

Parameters
string$a_auth_mode
Returns
string auth_mode

Definition at line 54 of file class.ilAuthProviderLTI.php.

54 : string
55 {
56 $auth_arr = explode('_', $a_auth_key);
57 if (count($auth_arr) > 1) {
58 return 'lti_' . $auth_arr[1];
59 }
60 return 'lti';
61 }

Referenced by ilAuthUtils\_getAuthModeName().

+ Here is the caller graph for this function:

◆ getAuthModes()

static ilAuthProviderLTI::getAuthModes ( )
static
Returns
array

Definition at line 99 of file class.ilAuthProviderLTI.php.

99 : array
100 {
101 global $ilDB;
102
103 // move to connector
104 $query = 'SELECT distinct(consumer_pk) consumer_pk from lti2_consumer';
105 $res = $ilDB->query($query);
106
107 $sids = array();
108 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
109 $sids[] = $row->consumer_pk;
110 }
111 return $sids;
112 }

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

Referenced by ilAuthUtils\_getActiveAuthModes(), and ilAuthUtils\_getAllAuthModes().

+ Here is the caller graph for this function:

◆ getKeyByAuthMode()

static ilAuthProviderLTI::getKeyByAuthMode ( string  $a_auth_mode)
static

Get auth id by auth mode.

Parameters
string$a_auth_mode
Returns
int|string auth_mode

Definition at line 68 of file class.ilAuthProviderLTI.php.

69 {
70 $auth_arr = explode('_', $a_auth_mode);
71 if (count($auth_arr) > 1) {
72 return ilAuthUtils::AUTH_PROVIDER_LTI . '_' . $auth_arr[1];
73 }
75 }
const int AUTH_PROVIDER_LTI

References ilAuthUtils\AUTH_PROVIDER_LTI.

Referenced by ilAuthUtils\_getAuthMode().

+ Here is the caller graph for this function:

◆ getServerIdByAuthMode()

static ilAuthProviderLTI::getServerIdByAuthMode ( string  $a_auth_mode)
static

Get auth id by auth mode.

Parameters
string$a_auth_mode
Returns
int|null

Definition at line 134 of file class.ilAuthProviderLTI.php.

134 : ?int
135 {
136 if (self::isAuthModeLTI($a_auth_mode)) {
137 $auth_arr = explode('_', $a_auth_mode);
138 return (int) $auth_arr[1];
139 }
140 return null;
141 }

Referenced by ilAuthUtils\getAuthModeTranslation().

+ Here is the caller graph for this function:

◆ handleLocalRoleAssignments()

ilAuthProviderLTI::handleLocalRoleAssignments ( int  $user_id,
ilLTIPlatform  $consumer,
int  $target_ref_id,
?int  $default_rol_id = null 
)
protected

Definition at line 535 of file class.ilAuthProviderLTI.php.

535 : bool
536 {
537 global $DIC;
538 $this->getLogger()->info('$target_ref_id: ' . $target_ref_id);
539 if (!$target_ref_id) {
540 $this->getLogger()->warning('No target id given');
541 return false;
542 }
543
544 $obj_settings = new ilLTIProviderObjectSetting($target_ref_id, $consumer->getExtConsumerId());
545
546 $roles = $this->messageParameters['roles'] ?? '';
547
548 if (!is_string($roles) || empty($roles)) {
549 $this->getLogger()->warning('No role information given or invalid role format.');
550 return false;
551 }
552
553 $this->getLogger()->info("Deassigning all roles for user: " . $user_id);
554 $DIC->rbac()->admin()->deassignUser($obj_settings->getTutorRole(), $user_id);
555 $DIC->rbac()->admin()->deassignUser($obj_settings->getMemberRole(), $user_id);
556 $DIC->rbac()->admin()->deassignUser($obj_settings->getAdminRole(), $user_id);
557
558 $role_arr = is_array($roles) ? $roles : explode(',', $roles);
559
560 $this->getLogger()->info('Recieved roles: ' . implode(', ', $role_arr));
561
562 $tree = $DIC->repositoryTree();
563 $parent = $tree->getParentId($target_ref_id);
564 if ($parent != 1) {
565 $this->handleLocalRoleAssignments($user_id, $consumer, $parent, $obj_settings->getMemberRole());
566 }
567 foreach ($role_arr as $role) {
568 $role = trim($role);
569 $local_role_id = $this->mapLTIRoleToLocalRole($role, $obj_settings) == 0 && $default_rol_id != null ? $default_rol_id : $this->mapLTIRoleToLocalRole($role, $obj_settings);
570 if (isset($local_role_id)) {
571 $this->getLogger()->info('Assigning local role ID: ' . $local_role_id . ' for LTI role: ' . $role . ' to user ID: ' . $user_id);
572 $DIC->rbac()->admin()->assignUser($local_role_id, $user_id);
573 } else {
574 $this->getLogger()->info('No local role mapping found for LTI role: ' . $role);
575 }
576 }
577
578 return true;
579 }
mapLTIRoleToLocalRole(string $lti_role, ilLTIProviderObjectSetting $settings)
Maps an LTI role (URI or simple name) to a local ILIAS role ID.
handleLocalRoleAssignments(int $user_id, ilLTIPlatform $consumer, int $target_ref_id, ?int $default_rol_id=null)

References $DIC, $user_id, ilLTIPlatform\getExtConsumerId(), ilAuthProvider\getLogger(), handleLocalRoleAssignments(), and mapLTIRoleToLocalRole().

Referenced by handleLocalRoleAssignments().

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

◆ isAuthModeLTI()

static ilAuthProviderLTI::isAuthModeLTI ( string  $a_auth_mode)
static

Check if user auth mode is LTI.

Parameters
string$a_auth_mode
Returns
bool

Definition at line 148 of file class.ilAuthProviderLTI.php.

148 : bool
149 {
150 if (!$a_auth_mode) {
151 ilLoggerFactory::getLogger('ltis')->warning('No auth mode given.');
152 return false;
153 }
154 $auth_arr = explode('_', $a_auth_mode);
155 return ($auth_arr[0] == ilAuthUtils::AUTH_PROVIDER_LTI) and $auth_arr[1];
156 }

References ilAuthUtils\AUTH_PROVIDER_LTI, and ilLoggerFactory\getLogger().

+ Here is the call graph for this function:

◆ lookupConsumer()

static ilAuthProviderLTI::lookupConsumer ( int  $a_sid)
static

Lookup consumer title.

Parameters
int$a_sid
Returns
string

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

119 : string
120 {
121 $connector = new ilLTIDataConnector();
122 $consumer = ilLTIPlatform::fromRecordId($a_sid, $connector);
123
124 $object_ref = $consumer->getRefId();
125 $object_title = ilObject2::_lookupTitle(ilObject2::_lookupObjectId($object_ref));
126 return $consumer->getTitle() . " / " . $object_title;
127 }
static fromRecordId(int|string $id, DataConnector $dataConnector)
Load the platform from the database by its record ID.
static _lookupObjectId(int $ref_id)
static _lookupTitle(int $obj_id)

References ilObject\_lookupObjectId(), ilObject\_lookupTitle(), and ilLTIPlatform\fromRecordId().

Referenced by ilAuthUtils\getAuthModeTranslation().

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

◆ mapLTIRoleToLocalRole()

ilAuthProviderLTI::mapLTIRoleToLocalRole ( string  $lti_role,
ilLTIProviderObjectSetting  $settings 
)
protected

Maps an LTI role (URI or simple name) to a local ILIAS role ID.

Parameters
string$lti_role
ilLTIProviderObjectSetting$settings
Returns
int|null The ILIAS role ID, or null if no mapping is found.

Definition at line 588 of file class.ilAuthProviderLTI.php.

588 : ?int
589 {
590 // Prioritize more specific roles (sub-roles)
591 $role_map = [
592 // System Roles
593 'http://purl.imsglobal.org/vocab/lti/system/person#TestUser' => null, // Example: No mapping for TestUser
594 'http://purl.imsglobal.org/vocab/lis/v2/system/person#Administrator' => $settings->getAdminRole(),
595 'http://purl.imsglobal.org/vocab/lis/v2/system/person#None' => null,
596 'http://purl.imsglobal.org/vocab/lis/v2/system/person#AccountAdmin' => null, // No direct mapping
597 'http://purl.imsglobal.org/vocab/lis/v2/system/person#Creator' => null, // No direct mapping
598 'http://purl.imsglobal.org/vocab/lis/v2/system/person#SysAdmin' => null, // No direct mapping
599 'http://purl.imsglobal.org/vocab/lis/v2/system/person#SysSupport' => null, // No direct mapping
600 'http://purl.imsglobal.org/vocab/lis/v2/system/person#User' => null, // No direct mapping
601
602 // Institution Roles
603 'http://purl.imsglobal.org/vocab/lis/v2/institution/person#Administrator' => $settings->getAdminRole(),
604 'http://purl.imsglobal.org/vocab/lis/v2/institution/person#Faculty' => $settings->getTutorRole(),
605 'http://purl.imsglobal.org/vocab/lis/v2/institution/person#Guest' => null, // No direct mapping
606 'http://purl.imsglobal.org/vocab/lis/v2/institution/person#None' => null,
607 'http://purl.imsglobal.org/vocab/lis/v2/institution/person#Other' => null, // No direct mapping
608 'http://purl.imsglobal.org/vocab/lis/v2/institution/person#Staff' => null, // No direct mapping
609 'http://purl.imsglobal.org/vocab/lis/v2/institution/person#Student' => $settings->getMemberRole(),
610 'http://purl.imsglobal.org/vocab/lis/v2/institution/person#Alumni' => null, // No direct mapping
611 'http://purl.imsglobal.org/vocab/lis/v2/institution/person#Instructor' => $settings->getTutorRole(),
612 'http://purl.imsglobal.org/vocab/lis/v2/institution/person#Learner' => $settings->getMemberRole(),
613 'http://purl.imsglobal.org/vocab/lis/v2/institution/person#Member' => $settings->getMemberRole(),
614 'http://purl.imsglobal.org/vocab/lis/v2/institution/person#Mentor' => null, // No direct mapping
615 'http://purl.imsglobal.org/vocab/lis/v2/institution/person#Observer' => null, // No direct mapping
616 'http://purl.imsglobal.org/vocab/lis/v2/institution/person#ProspectiveStudent' => null, // No direct mapping
617
618 // Context Roles (Main)
619 'http://purl.imsglobal.org/vocab/lis/v2/membership#Administrator' => $settings->getAdminRole(),
620 'http://purl.imsglobal.org/vocab/lis/v2/membership#ContentDeveloper' => null, // No direct mapping
621 'http://purl.imsglobal.org/vocab/lis/v2/membership#Instructor' => $settings->getTutorRole(),
622 'http://purl.imsglobal.org/vocab/lis/v2/membership#Learner' => $settings->getMemberRole(),
623 'http://purl.imsglobal.org/vocab/lis/v2/membership#Mentor' => null, // No direct mapping
624 'http://purl.imsglobal.org/vocab/lis/v2/membership#Manager' => $settings->getAdminRole(), // Potentially map to admin
625 'http://purl.imsglobal.org/vocab/lis/v2/membership#Member' => $settings->getMemberRole(),
626 'http://purl.imsglobal.org/vocab/lis/v2/membership#Officer' => null, // No direct mapping
627
628 // Context Sub-Roles (TeachingAssistant)
629 'http://purl.imsglobal.org/vocab/lis/v2/membership/Instructor#TeachingAssistant' => $settings->getTutorRole(),
630 'http://purl.imsglobal.org/vocab/lis/v2/membership/Instructor#TeachingAssistantGroup' => $settings->getTutorRole(),
631 'http://purl.imsglobal.org/vocab/lis/v2/membership/Instructor#TeachingAssistantOffering' => $settings->getTutorRole(),
632 'http://purl.imsglobal.org/vocab/lis/v2/membership/Instructor#TeachingAssistantSection' => $settings->getTutorRole(),
633 'http://purl.imsglobal.org/vocab/lis/v2/membership/Instructor#TeachingAssistantSectionAssociation' => $settings->getTutorRole(),
634 'http://purl.imsglobal.org/vocab/lis/v2/membership/Instructor#TeachingAssistantTemplate' => $settings->getTutorRole(),
635 // Context Sub-Roles (Grader)
636 'http://purl.imsglobal.org/vocab/lis/v2/membership/Instructor#Grader' => $settings->getTutorRole(), // Map Grader to Tutor
637 // Context Sub-Roles (GuestInstructor, Lecturer, PrimaryInstructor, SecondaryInstructor)
638 'http://purl.imsglobal.org/vocab/lis/v2/membership/Instructor#GuestInstructor' => $settings->getTutorRole(),
639 'http://purl.imsglobal.org/vocab/lis/v2/membership/Instructor#Lecturer' => $settings->getTutorRole(),
640 'http://purl.imsglobal.org/vocab/lis/v2/membership/Instructor#PrimaryInstructor' => $settings->getTutorRole(),
641 'http://purl.imsglobal.org/vocab/lis/v2/membership/Instructor#SecondaryInstructor' => $settings->getTutorRole(),
642 // Context Sub-Roles (ExternalInstructor)
643 'http://purl.imsglobal.org/vocab/lis/v2/membership/Instructor#ExternalInstructor' => $settings->getTutorRole(),
644
645 // Context Sub-Roles (ExternalLearner, GuestLearner, Learner, NonCreditLearner)
646 'http://purl.imsglobal.org/vocab/lis/v2/membership/Learner#ExternalLearner' => $settings->getMemberRole(),
647 'http://purl.imsglobal.org/vocab/lis/v2/membership/Learner#GuestLearner' => $settings->getMemberRole(),
648 'http://purl.imsglobal.org/vocab/lis/v2/membership/Learner#Learner' => $settings->getMemberRole(),
649 'http://purl.imsglobal.org/vocab/lis/v2/membership/Learner#NonCreditLearner' => $settings->getMemberRole(),
650
651 // Context Sub-Roles (AreaManager, CourseCoordinator, ExternalObserver, Manager, Observer)
652 'http://purl.imsglobal.org/vocab/lis/v2/membership/Manager#AreaManager' => $settings->getAdminRole(),
653 'http://purl.imsglobal.org/vocab/lis/v2/membership/Manager#CourseCoordinator' => null,
654 'http://purl.imsglobal.org/vocab/lis/v2/membership/Manager#ExternalObserver' => null,
655 'http://purl.imsglobal.org/vocab/lis/v2/membership/Manager#Manager' => $settings->getAdminRole(),
656 'http://purl.imsglobal.org/vocab/lis/v2/membership/Manager#Observer' => null,
657
658 // Context Sub-Roles (Advisor, Auditor, ExternalAdvisor, ExternalAuditor, ExternalLearningFacilitator, ExternalMentor, ExternalReviewer, ExternalTutor, LearningFacilitator, Mentor, Reviewer, Tutor)
659 'http://purl.imsglobal.org/vocab/lis/v2/membership/Mentor#Advisor' => null,
660 'http://purl.imsglobal.org/vocab/lis/v2/membership/Mentor#Auditor' => null,
661 'http://purl.imsglobal.org/vocab/lis/v2/membership/Mentor#ExternalAdvisor' => null,
662 'http://purl.imsglobal.org/vocab/lis/v2/membership/Mentor#ExternalAuditor' => null,
663 'http://purl.imsglobal.org/vocab/lis/v2/membership/Mentor#ExternalLearningFacilitator' => null,
664 'http://purl.imsglobal.org/vocab/lis/v2/membership/Mentor#ExternalMentor' => null,
665 'http://purl.imsglobal.org/vocab/lis/v2/membership/Mentor#ExternalReviewer' => null,
666 'http://purl.imsglobal.org/vocab/lis/v2/membership/Mentor#ExternalTutor' => null,
667 'http://purl.imsglobal.org/vocab/lis/v2/membership/Mentor#LearningFacilitator' => null,
668 'http://purl.imsglobal.org/vocab/lis/v2/membership/Mentor#Mentor' => null,
669 'http://purl.imsglobal.org/vocab/lis/v2/membership/Mentor#Reviewer' => null,
670 'http://purl.imsglobal.org/vocab/lis/v2/membership/Mentor#Tutor' => $settings->getTutorRole(), // Map Tutor to Tutor
671
672 // Context Sub-Roles (Chair, Communications, Secretary, Treasurer, Vice-Chair)
673 'http://purl.imsglobal.org/vocab/lis/v2/membership/Officer#Chair' => null,
674 'http://purl.imsglobal.org/vocab/lis/v2/membership/Officer#Communications' => null,
675 'http://purl.imsglobal.org/vocab/lis/v2/membership/Officer#Secretary' => null,
676 'http://purl.imsglobal.org/vocab/lis/v2/membership/Officer#Treasurer' => null,
677 'http://purl.imsglobal.org/vocab/lis/v2/membership/Officer#Vice-Chair' => null,
678
679 // Context Sub-Roles (ContentDeveloper, ContentExpert, ExternalContentExpert, Librarian)
680 'http://purl.imsglobal.org/vocab/lis/v2/membership/ContentDeveloper#ContentDeveloper' => null,
681 'http://purl.imsglobal.org/vocab/lis/v2/membership/ContentDeveloper#ContentExpert' => null,
682 'http://purl.imsglobal.org/vocab/lis/v2/membership/ContentDeveloper#ExternalContentExpert' => null,
683 'http://purl.imsglobal.org/vocab/lis/v2/membership/ContentDeveloper#Librarian' => null,
684
685 // Context Sub-Roles (Member)
686 'http://purl.imsglobal.org/vocab/lis/v2/membership/Member#Member' => $settings->getMemberRole(),
687
688 // Context Sub-Roles (Administrator, Developer, ExternalDeveloper, ExternalSupport, ExternalSystemAdministrator, Support, SystemAdministrator)
689 'http://purl.imsglobal.org/vocab/lis/v2/membership/Administrator#Administrator' => $settings->getAdminRole(),
690 'http://purl.imsglobal.org/vocab/lis/v2/membership/Administrator#Developer' => null,
691 'http://purl.imsglobal.org/vocab/lis/v2/membership/Administrator#ExternalDeveloper' => null,
692 'http://purl.imsglobal.org/vocab/lis/v2/membership/Administrator#ExternalSupport' => null,
693 'http://purl.imsglobal.org/vocab/lis/v2/membership/Administrator#ExternalSystemAdministrator' => null,
694 'http://purl.imsglobal.org/vocab/lis/v2/membership/Administrator#Support' => null,
695 'http://purl.imsglobal.org/vocab/lis/v2/membership/Administrator#SystemAdministrator' => null,
696 ];
697
698 // LTI 1.0/1.1 simple names (supported for backward compatibility)
699 $simple_name_map = [
700 'Instructor' => $settings->getTutorRole(),
701 'Learner' => $settings->getMemberRole(),
702 'ContentDeveloper' => null,
703 'Administrator' => $settings->getAdminRole(),
704 'Mentor' => null,
705 'Manager' => $settings->getAdminRole(),
706 'Member' => $settings->getMemberRole(),
707 'Officer' => null,
708 ];
709
710
711 if (isset($role_map[$lti_role])) {
712 return $role_map[$lti_role];
713 } elseif (isset($simple_name_map[$lti_role])) {
714 // Check for simple names
715 return $simple_name_map[$lti_role];
716 }
717
718 return null;
719 }

References ilLTIProviderObjectSetting\getAdminRole(), ilLTIProviderObjectSetting\getMemberRole(), and ilLTIProviderObjectSetting\getTutorRole().

Referenced by handleLocalRoleAssignments().

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

◆ updateUser()

ilAuthProviderLTI::updateUser ( int  $a_local_user_id,
ilLTIPlatform  $consumer 
)
protected

update existing user @access protected

Parameters
int$a_local_user_id
ilLTIPlatform$consumer
Returns
int

Definition at line 380 of file class.ilAuthProviderLTI.php.

380 : int
381 {
382 global $ilClientIniFile, $DIC;
383 // if (empty($this->messageParameters)) {
384 // $status->setReason('empty_lti_message_parameters');
385 // $status->setStatus(ilAuthStatus::STATUS_AUTHENTICATION_FAILED);
386 // return false;
387 // }
388 $user_obj = new ilObjUser($a_local_user_id);
389 if (isset($this->messageParameters['lis_person_name_given'])) {
390 $user_obj->setFirstname($this->messageParameters['lis_person_name_given']);
391 } else {
392 $user_obj->setFirstname('-');
393 }
394 if (isset($this->messageParameters['lis_person_name_family'])) {
395 $user_obj->setLastname($this->messageParameters['lis_person_name_family']);
396 } else {
397 $user_obj->setLastname('-');
398 }
399 $user_obj->setEmail($this->messageParameters['lis_person_contact_email_primary']);
400
401 $user_obj->setActive(true);
402
403 $until = $user_obj->getTimeLimitUntil();
404
405 if ($until < (time() + (int) $ilClientIniFile->readVariable('session', 'expire'))) {
406 $user_obj->setTimeLimitFrom(time() - 60);
407 $user_obj->setTimeLimitUntil(time() + (int) $ilClientIniFile->readVariable("session", "expire"));
408 }
409 $user_obj->refreshLogin();
410 $user_obj->update();
411
412 $GLOBALS['DIC']->rbac()->admin()->assignUser($consumer->getRole(), $user_obj->getId());
413 $this->getLogger()->debug('Assigned user to: ' . $consumer->getRole());
414
415 $this->getLogger()->info('Update of lti user with uid: ' . $user_obj->getId() . ' and login: ' . $user_obj->getLogin());
416 return $user_obj->getId();
417 }

References $DIC, $GLOBALS, ilAuthProvider\getLogger(), and ilLTIPlatform\getRole().

+ Here is the call graph for this function:

Field Documentation

◆ $dataConnector

ilLTIDataConnector ilAuthProviderLTI::$dataConnector = null
private

Definition at line 30 of file class.ilAuthProviderLTI.php.

◆ $launchReturnUrl

string ilAuthProviderLTI::$launchReturnUrl = ""
protected

Definition at line 36 of file class.ilAuthProviderLTI.php.

◆ $logger

ilLogger ilAuthProviderLTI::$logger = null
private

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

◆ $lti_context_id

string ilAuthProviderLTI::$lti_context_id = ""
private

Definition at line 31 of file class.ilAuthProviderLTI.php.

◆ $messageParameters

array ilAuthProviderLTI::$messageParameters = null
private

Definition at line 34 of file class.ilAuthProviderLTI.php.

◆ $provider

ilLTITool ilAuthProviderLTI::$provider = null
private

Definition at line 33 of file class.ilAuthProviderLTI.php.

◆ $ref_id

int ilAuthProviderLTI::$ref_id = 0
private

Definition at line 32 of file class.ilAuthProviderLTI.php.

◆ AUTH_MODE_PREFIX

const ilAuthProviderLTI::AUTH_MODE_PREFIX = 'lti'

Definition at line 29 of file class.ilAuthProviderLTI.php.


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