ILIAS  trunk Revision v11.0_alpha-1831-g8615d53dadb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilAuthProviderSoap Class Reference
+ Inheritance diagram for ilAuthProviderSoap:
+ Collaboration diagram for ilAuthProviderSoap:

Public Member Functions

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

Protected Attributes

string $server_host = ''
 
string $server_port = ''
 
string $server_uri = ''
 
bool $server_https = false
 
string $server_nms = ''
 
bool $use_dot_net = false
 
string $uri = ''
 
nusoap_client $client
 
ilLogger $logger
 
ilSetting $settings
 
ilLanguage $language
 
ilRbacAdmin $rbacAdmin
 

Private Member Functions

 initClient ()
 
 handleSoapAuth (ilAuthStatus $status)
 

Additional Inherited Members

- Protected Member Functions inherited from ilAuthProvider
 handleAuthenticationFail (ilAuthStatus $status, string $a_reason)
 Handle failed authentication. More...
 

Detailed Description

Definition at line 21 of file class.ilAuthProviderSoap.php.

Constructor & Destructor Documentation

◆ __construct()

ilAuthProviderSoap::__construct ( ilAuthCredentials  $credentials)

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

References $DIC, ILIAS\GlobalScreen\Provider\__construct(), ILIAS\UI\examples\Symbol\Glyph\Language\language(), ILIAS\Repository\logger(), and ILIAS\Repository\settings().

37  {
38  global $DIC;
39 
40  $this->settings = $DIC->settings();
41  $this->logger = $DIC->logger()->auth();
42  $this->language = $DIC->language();
43  $this->rbacAdmin = $DIC->rbac()->admin();
44 
45  parent::__construct($credentials);
46  }
global $DIC
Definition: shib_login.php:22
__construct(Container $dic, ilPlugin $plugin)
language()
description: > Example for rendring a language glyph.
Definition: language.php:41
+ Here is the call graph for this function:

Member Function Documentation

◆ doAuthentication()

ilAuthProviderSoap::doAuthentication ( ilAuthStatus  $status)

Definition at line 74 of file class.ilAuthProviderSoap.php.

References Vendor\Package\$e, ANONYMOUS_USER_ID, ilAuthUtils\AUTH_SOAP, ilAuthStatus\getAuthenticatedUserId(), ilAuthProvider\getCredentials(), ilAuthProvider\getLogger(), handleSoapAuth(), initClient(), ILIAS\Repository\logger(), ilSession\set(), ilAuthStatus\setStatus(), ilAuthStatus\setTranslatedReason(), ilAuthStatus\STATUS_AUTHENTICATED, and ilAuthStatus\STATUS_AUTHENTICATION_FAILED.

74  : bool
75  {
76  try {
77  $this->initClient();
78  $this->handleSoapAuth($status);
79  } catch (Exception $e) {
80  $this->getLogger()->error($e->getMessage());
81  $this->getLogger()->error($e->getTraceAsString());
82  $status->setTranslatedReason($e->getMessage());
83  }
84 
85  if ($status->getAuthenticatedUserId() > 0 && $status->getAuthenticatedUserId() !== ANONYMOUS_USER_ID) {
86  $this->logger->info('Successfully authenticated user via SOAP: ' . $this->getCredentials()->getUsername());
88  ilSession::set('used_external_auth_mode', ilAuthUtils::AUTH_SOAP);
89 
90  return true;
91  }
92 
94 
95  return false;
96  }
const ANONYMOUS_USER_ID
Definition: constants.php:27
const STATUS_AUTHENTICATION_FAILED
handleSoapAuth(ilAuthStatus $status)
getAuthenticatedUserId()
Get authenticated user id.
setStatus(int $a_status)
Set auth status.
getLogger()
Get logger.
setTranslatedReason(string $a_reason)
Set translated reason.
static set(string $a_var, $a_val)
Set a value.
+ Here is the call graph for this function:

◆ handleSoapAuth()

ilAuthProviderSoap::handleSoapAuth ( ilAuthStatus  $status)
private

Definition at line 98 of file class.ilAuthProviderSoap.php.

References $valid, ilObjUser\_checkExternalAuthAccount(), ilAuthUtils\_generateLogin(), ilObjUser\_lookupId(), ILIAS\UI\examples\Progress\Bar\client(), ilSecuritySettingsChecker\generatePasswords(), ilAuthProvider\getCredentials(), ILIAS\UI\examples\Symbol\Glyph\Language\language(), ILIAS\Repository\logger(), null, ilObjUser\PASSWD_CRYPTED, ilObjUser\PASSWD_PLAIN, ilAuthStatus\setAuthenticatedUserId(), ilAuthStatus\setReason(), ILIAS\Repository\settings(), ilAuthStatus\setTranslatedReason(), and USER_FOLDER_ID.

Referenced by doAuthentication().

98  : bool
99  {
100  $this->logger->debug(sprintf(
101  'Login observer called for SOAP authentication request of ext_account "%s" and auth_mode "%s".',
102  $this->getCredentials()->getUsername(),
103  'soap'
104  ));
105  $this->logger->debug(sprintf(
106  'Trying to find ext_account "%s" for auth_mode "%s".',
107  $this->getCredentials()->getUsername(),
108  'soap'
109  ));
110 
111  $internalLogin = ilObjUser::_checkExternalAuthAccount(
112  'soap',
113  $this->getCredentials()->getUsername()
114  );
115 
116  $isNewUser = false;
117  if ('' === $internalLogin || null === $internalLogin) {
118  $isNewUser = true;
119  }
120 
121  $soapAction = '';
122  $nspref = '';
123  if ($this->use_dot_net) {
124  $soapAction = $this->server_nms . '/isValidSession';
125  $nspref = 'ns1:';
126  }
127 
128  $valid = $this->client->call(
129  'isValidSession',
130  [
131  $nspref . 'ext_uid' => $this->getCredentials()->getUsername(),
132  $nspref . 'soap_pw' => $this->getCredentials()->getPassword(),
133  $nspref . 'new_user' => $isNewUser
134  ],
135  $this->server_nms,
136  $soapAction
137  );
138 
139  if (!is_array($valid)) {
140  $valid = ['valid' => false];
141  }
142 
143  if ($valid['valid'] !== true) {
144  $valid['valid'] = false;
145  }
146 
147  if (!$valid['valid']) {
148  $status->setReason('err_wrong_login');
149  return false;
150  }
151 
152  if (!$isNewUser) {
153  $status->setAuthenticatedUserId(ilObjUser::_lookupId($internalLogin));
154  return true;
155  }
156 
157  if (!$this->settings->get('soap_auth_create_users')) {
158  // Translate the reasons, otherwise the default failure is displayed
159  $status->setTranslatedReason($this->language->txt('err_valid_login_account_creation_disabled'));
160  return false;
161  }
162 
163  $userObj = new ilObjUser();
164  $internalLogin = ilAuthUtils::_generateLogin($this->getCredentials()->getUsername());
165 
166  $usrData = [];
167  $usrData['firstname'] = $valid['firstname'];
168  $usrData['lastname'] = $valid['lastname'];
169  $usrData['email'] = $valid['email'];
170  $usrData['login'] = $internalLogin;
171  $usrData['passwd'] = '';
172  $usrData['passwd_type'] = ilObjUser::PASSWD_CRYPTED;
173 
174  $password = '';
175  if ($this->settings->get('soap_auth_allow_local')) {
177  $password = $passwords[0];
178  $usrData['passwd'] = $password;
179  $usrData['passwd_type'] = ilObjUser::PASSWD_PLAIN;
180  }
181 
182  $usrData['auth_mode'] = 'soap';
183  $usrData['ext_account'] = $this->getCredentials()->getUsername();
184  $usrData['profile_incomplete'] = 1;
185 
186  $userObj->assignData($usrData);
187  $userObj->setTitle($userObj->getFullname());
188  $userObj->setDescription($userObj->getEmail());
189  $userObj->setLanguage($this->language->getDefaultLanguage());
190 
191  $userObj->setTimeLimitOwner(USER_FOLDER_ID);
192  $userObj->setTimeLimitUnlimited(true);
193  $userObj->setTimeLimitFrom(time());
194  $userObj->setTimeLimitUntil(time());
195  $userObj->setOwner(0);
196  $userObj->create();
197  $userObj->setActive(true);
198  $userObj->updateOwner();
199  $userObj->saveAsNew();
200  $userObj->writePrefs();
201 
202  $this->rbacAdmin->assignUser(
203  (int) $this->settings->get('soap_auth_user_default_role', '4'),
204  $userObj->getId()
205  );
206 
207  if ($this->settings->get('soap_auth_account_mail', '0')) {
208  $registrationSettings = new ilRegistrationSettings();
209  $registrationSettings->setPasswordGenerationStatus(true);
210 
211  $accountMail = new ilAccountRegistrationMail(
212  $registrationSettings,
213  $this->language,
214  $this->logger
215  );
216  $accountMail
217  ->withDirectRegistrationMode()
218  ->send($userObj, $password, false);
219  }
220 
221  $status->setAuthenticatedUserId($userObj->getId());
222  return true;
223  }
static _generateLogin(string $a_login)
generate free login by starting with a default string and adding postfix numbers
const USER_FOLDER_ID
Definition: constants.php:33
$valid
const PASSWD_PLAIN
static _lookupId($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
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
Class ilAccountRegistrationMail.
const PASSWD_CRYPTED
static generatePasswords(int $a_number)
Generate a number of passwords.
Class ilObjAuthSettingsGUI.
client()
description: > This example shows how a Progress Bar can be rendered and used on the client...
Definition: client.php:37
setTranslatedReason(string $a_reason)
Set translated reason.
setReason(string $a_reason)
Set reason.
setAuthenticatedUserId(int $a_id)
language()
description: > Example for rendring a language glyph.
Definition: language.php:41
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initClient()

ilAuthProviderSoap::initClient ( )
private

Definition at line 48 of file class.ilAuthProviderSoap.php.

References $server_host, $server_port, $server_uri, ILIAS\UI\examples\Progress\Bar\client(), and ILIAS\Repository\settings().

Referenced by doAuthentication().

48  : void
49  {
50  $this->server_host = (string) $this->settings->get('soap_auth_server', '');
51  $this->server_port = (string) $this->settings->get('soap_auth_port', '');
52  $this->server_uri = (string) $this->settings->get('soap_auth_uri', '');
53  $this->server_nms = (string) $this->settings->get('soap_auth_namespace', '');
54  $this->server_https = (bool) $this->settings->get('soap_auth_use_https', '0');
55  $this->use_dot_net = (bool) $this->settings->get('use_dotnet', '0');
56 
57  $this->uri = $this->server_https ? 'https://' : 'http://';
58  $this->uri .= $this->server_host;
59 
60  if ($this->server_port > 0) {
61  $this->uri .= (':' . $this->server_port);
62  }
63  if ($this->server_uri) {
64  $this->uri .= ('/' . $this->server_uri);
65  }
66 
67  require_once __DIR__ . '/../../soap/lib/nusoap.php';
68  $this->client = new nusoap_client($this->uri);
69  }
[nu]soapclient higher level class for easy usage.
Definition: nusoap.php:7182
client()
description: > This example shows how a Progress Bar can be rendered and used on the client...
Definition: client.php:37
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $client

nusoap_client ilAuthProviderSoap::$client
protected

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

◆ $language

ilLanguage ilAuthProviderSoap::$language
protected

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

◆ $logger

ilLogger ilAuthProviderSoap::$logger
protected

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

◆ $rbacAdmin

ilRbacAdmin ilAuthProviderSoap::$rbacAdmin
protected

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

◆ $server_host

string ilAuthProviderSoap::$server_host = ''
protected

Definition at line 23 of file class.ilAuthProviderSoap.php.

Referenced by initClient().

◆ $server_https

bool ilAuthProviderSoap::$server_https = false
protected

Definition at line 26 of file class.ilAuthProviderSoap.php.

◆ $server_nms

string ilAuthProviderSoap::$server_nms = ''
protected

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

◆ $server_port

string ilAuthProviderSoap::$server_port = ''
protected

Definition at line 24 of file class.ilAuthProviderSoap.php.

Referenced by initClient().

◆ $server_uri

string ilAuthProviderSoap::$server_uri = ''
protected

Definition at line 25 of file class.ilAuthProviderSoap.php.

Referenced by initClient().

◆ $settings

ilSetting ilAuthProviderSoap::$settings
protected

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

◆ $uri

string ilAuthProviderSoap::$uri = ''
protected

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

◆ $use_dot_net

bool ilAuthProviderSoap::$use_dot_net = false
protected

Definition at line 28 of file class.ilAuthProviderSoap.php.


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