ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilAuthProviderShibboleth.php
Go to the documentation of this file.
1<?php
2
24{
25 private ILIAS $ilias;
27
29 {
30 global $DIC;
31 $this->ilias = $DIC['ilias'];
32 $this->settings = $DIC->settings();
34 }
35
43 public function doAuthentication(ilAuthStatus $status): bool
44 {
45 $shib_server_data = shibServerData::getInstance();
46
47 if ($shib_server_data->getLogin() !== '' && $shib_server_data->getLogin() !== '0') {
48 $shib_user = shibUser::buildInstance($shib_server_data);
49 // for backword compatibility of hook environment variables
50 $new_user = $shib_user->isNew(); // For shib_data_conv included Script
52 $account_creation = $settings->getAccountCreation();
53 if (!$new_user) {
54 $shib_user->updateFields();
55 // Include custom code that can be used to further modify
56 // certain Shibboleth user attributes
57 if (
58 $this->ilias->getSetting('shib_data_conv') &&
59 $this->ilias->getSetting('shib_data_conv') !== '' &&
60 is_readable($this->ilias->getSetting('shib_data_conv'))
61 ) {
63 include($this->ilias->getSetting('shib_data_conv'));
64 }
65 $shib_user = ilShibbolethPluginWrapper::getInstance()->beforeUpdateUser($shib_user);
66 $shib_user->update();
67 $shib_user = ilShibbolethPluginWrapper::getInstance()->afterUpdateUser($shib_user);
69 } elseif ($account_creation !== ilShibbolethSettings::ACCOUNT_CREATION_DISABLED) {
70 $shib_user->createFields();
71 $shib_user->setPref('hits_per_page', $this->settings->get('hits_per_page'));
72
73 // Modify user data before creating the user
74 // Include custom code that can be used to further modify
75 // certain Shibboleth user attributes
76 if (
77 $this->ilias->getSetting('shib_data_conv') &&
78 $this->ilias->getSetting('shib_data_conv', '') !== '' &&
79 is_readable($this->ilias->getSetting('shib_data_conv'))
80 ) {
82 include($this->ilias->getSetting('shib_data_conv'));
83 }
84 $shib_user = ilShibbolethPluginWrapper::getInstance()->beforeCreateUser($shib_user);
86 $shib_user->setActive(false);
87 }
88 $shib_user->create();
89 $shib_user->saveAsNew();
90 $shib_user->updateOwner();
91 $shib_user->writePrefs();
92 $shib_user = ilShibbolethPluginWrapper::getInstance()->afterCreateUser($shib_user);
94 }
95
96 if (!$new_user || $account_creation === ilShibbolethSettings::ACCOUNT_CREATION_ENABLED) {
98 $status->setAuthenticatedUserId(ilObjUser::_lookupId($shib_user->getLogin()));
99 } elseif ($account_creation === ilShibbolethSettings::ACCOUNT_CREATION_WITH_APPROVAL) {
101 $status->setReason('err_inactive');
102 } else {
104 $status->setReason('err_disabled');
105 }
106
107 } else {
108 $this->getLogger()->info('Shibboleth authentication failed.');
109 $this->handleAuthenticationFail($status, 'err_wrong_login');
110 return false;
111 }
112
113 return true;
114 }
115}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(ilAuthCredentials $credentials)
handleAuthenticationFail(ilAuthStatus $status, string $a_reason)
ilAuthCredentials $credentials
const int STATUS_AUTHENTICATION_FAILED
setReason(string $a_reason)
Set reason.
setAuthenticatedUserId(int $a_id)
setStatus(int $a_status)
Set auth status.
const int STATUS_AUTHENTICATED
static _lookupId(string|array $a_user_str)
ILIAS Setting Class.
static doAssignments(int $a_usr_id, array $a_data)
static updateAssignments(int $a_usr_id, array $a_data)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static buildInstance(shibServerData $shibServerData)
$new_user
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.
Class ilObjForumAdministration.
$_SERVER['HTTP_HOST']
Definition: raiseError.php:26
global $DIC
Definition: shib_login.php:26