ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilAuthProviderSoap Class Reference
+ Inheritance diagram for ilAuthProviderSoap:
+ Collaboration diagram for ilAuthProviderSoap:

Public Member Functions

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

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
 
ilDBInterface $db
 

Private Member Functions

 initClient ()
 
 handleSoapAuth (ilAuthStatus $status)
 

Additional Inherited Members

- Protected Member Functions inherited from ilAuthProvider
 handleAuthenticationFail (ilAuthStatus $status, string $a_reason)
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

ilAuthProviderSoap::__construct ( ilAuthCredentials  $credentials)

Reimplemented from ilAuthProvider.

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

40 {
41 global $DIC;
42
43 $this->settings = $DIC->settings();
44 $this->logger = $DIC->logger()->auth();
45 $this->language = $DIC->language();
46 $this->rbacAdmin = $DIC->rbac()->admin();
47 $this->db = $DIC->database();
48
50 }
ilAuthCredentials $credentials
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26

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

+ Here is the call graph for this function:

Member Function Documentation

◆ doAuthentication()

ilAuthProviderSoap::doAuthentication ( ilAuthStatus  $status)

@inheritDoc

Implements ilAuthProviderInterface.

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

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

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.

+ Here is the call graph for this function:

◆ handleSoapAuth()

ilAuthProviderSoap::handleSoapAuth ( ilAuthStatus  $status)
private

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

102 : bool
103 {
104 $this->logger->debug(sprintf(
105 'Login observer called for SOAP authentication request of ext_account "%s" and auth_mode "%s".',
106 $this->getCredentials()->getUsername(),
107 'soap'
108 ));
109 $this->logger->debug(sprintf(
110 'Trying to find ext_account "%s" for auth_mode "%s".',
111 $this->getCredentials()->getUsername(),
112 'soap'
113 ));
114
116 'soap',
117 $this->getCredentials()->getUsername()
118 );
119
120 $isNewUser = false;
121 if ('' === $internalLogin || null === $internalLogin) {
122 $isNewUser = true;
123 }
124
125 $soapAction = '';
126 $nspref = '';
127 if ($this->use_dot_net) {
128 $soapAction = $this->server_nms . '/isValidSession';
129 $nspref = 'ns1:';
130 }
131
132 $valid = $this->client->call(
133 'isValidSession',
134 [
135 $nspref . 'ext_uid' => $this->getCredentials()->getUsername(),
136 $nspref . 'soap_pw' => $this->getCredentials()->getPassword(),
137 $nspref . 'new_user' => $isNewUser
138 ],
139 $this->server_nms,
140 $soapAction
141 );
142
143 if (!is_array($valid)) {
144 $valid = ['valid' => false];
145 }
146
147 if ($valid['valid'] !== true) {
148 $valid['valid'] = false;
149 }
150
151 if (!$valid['valid']) {
152 $status->setReason('err_wrong_login');
153 return false;
154 }
155
156 if (!$isNewUser) {
157 $status->setAuthenticatedUserId(ilObjUser::_lookupId($internalLogin));
158 return true;
159 }
160
161 if (!$this->settings->get('soap_auth_create_users')) {
162 // Translate the reasons, otherwise the default failure is displayed
163 $status->setTranslatedReason($this->language->txt('err_valid_login_account_creation_disabled'));
164 return false;
165 }
166
167 $userObj = new ilObjUser();
168 $internalLogin = ilAuthUtils::_generateLogin($this->getCredentials()->getUsername());
169
170 $password = '';
171 $password_type = ilObjUser::PASSWD_CRYPTED;
172 if ($this->settings->get('soap_auth_allow_local')) {
174 $password = $passwords[0];
175 $password_type = ilObjUser::PASSWD_PLAIN;
176 }
177
178 $userObj->setLogin($internalLogin);
179 $userObj->setFirstname($user->getFirstname());
180 $userObj->setLastname($user->getLastname());
181 $userObj->setTitle($userObj->getFullname());
182 $userObj->setDescription($userObj->getEmail());
183 $userObj->setEmail($user->getEmail());
184 $userObj->setPasswd($password, $password_type);
185 $userObj->setAuthMode('soap');
186 $userObj->setExternalAccount($this->getCredentials()->getUsername());
187 $userObj->setLanguage($this->language->getDefaultLanguage());
188 $userObj->setProfileIncomplete(true);
189
190 $userObj->setTimeLimitUnlimited(true);
191 $userObj->setTimeLimitFrom(time());
192 $userObj->setTimeLimitUntil(time());
193 $userObj->setOwner(0);
194 $userObj->create();
195 $userObj->setActive(true);
196 $userObj->updateOwner();
197 $userObj->saveAsNew();
198 $userObj->writePrefs();
199
200 $this->rbacAdmin->assignUser(
201 (int) $this->settings->get('soap_auth_user_default_role', '4'),
202 $userObj->getId()
203 );
204
205 if ($this->settings->get('soap_auth_account_mail', '0')) {
206 $registrationSettings = new ilRegistrationSettings();
207 $registrationSettings->setPasswordGenerationStatus(true);
208
209 $accountMail = new ilAccountRegistrationMail(
210 $registrationSettings,
211 $this->logger,
212 new NewAccountMailRepository($this->db)
213 );
214 $accountMail
215 ->withDirectRegistrationMode()
216 ->send($userObj, $password, false);
217 }
218
219 $status->setAuthenticatedUserId($userObj->getId());
220 return true;
221 }
Class ilAccountRegistrationMail.
setReason(string $a_reason)
Set reason.
setAuthenticatedUserId(int $a_id)
static _generateLogin(string $a_login)
generate free login by starting with a default string and adding postfix numbers
User class.
const PASSWD_CRYPTED
const PASSWD_PLAIN
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
Class ilObjAuthSettingsGUI.
static generatePasswords(int $a_number)
Generate a number of passwords.
$valid

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(), ilObjUser\PASSWD_CRYPTED, ilObjUser\PASSWD_PLAIN, ilAuthStatus\setAuthenticatedUserId(), ilAuthStatus\setReason(), ILIAS\Repository\settings(), and ilAuthStatus\setTranslatedReason().

Referenced by doAuthentication().

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

◆ initClient()

ilAuthProviderSoap::initClient ( )
private

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

52 : void
53 {
54 $this->server_host = (string) $this->settings->get('soap_auth_server', '');
55 $this->server_port = (string) $this->settings->get('soap_auth_port', '');
56 $this->server_uri = (string) $this->settings->get('soap_auth_uri', '');
57 $this->server_nms = (string) $this->settings->get('soap_auth_namespace', '');
58 $this->server_https = (bool) $this->settings->get('soap_auth_use_https', '0');
59 $this->use_dot_net = (bool) $this->settings->get('use_dotnet', '0');
60
61 $this->uri = $this->server_https ? 'https://' : 'http://';
62 $this->uri .= $this->server_host;
63
64 if ($this->server_port > 0) {
65 $this->uri .= (':' . $this->server_port);
66 }
67 if ($this->server_uri) {
68 $this->uri .= ('/' . $this->server_uri);
69 }
70
71 require_once __DIR__ . '/../../soap/lib/nusoap.php';
72 $this->client = new nusoap_client($this->uri);
73 }
[nu]soapclient higher level class for easy usage.
Definition: nusoap.php:7179

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

Referenced by doAuthentication().

+ 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 32 of file class.ilAuthProviderSoap.php.

◆ $db

ilDBInterface ilAuthProviderSoap::$db
protected

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

◆ $language

ilLanguage ilAuthProviderSoap::$language
protected

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

◆ $logger

ilLogger ilAuthProviderSoap::$logger
protected

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

◆ $rbacAdmin

ilRbacAdmin ilAuthProviderSoap::$rbacAdmin
protected

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

◆ $server_host

string ilAuthProviderSoap::$server_host = ''
protected

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

Referenced by initClient().

◆ $server_https

bool ilAuthProviderSoap::$server_https = false
protected

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

◆ $server_nms

string ilAuthProviderSoap::$server_nms = ''
protected

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

◆ $server_port

string ilAuthProviderSoap::$server_port = ''
protected

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

Referenced by initClient().

◆ $server_uri

string ilAuthProviderSoap::$server_uri = ''
protected

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

Referenced by initClient().

◆ $settings

ilSetting ilAuthProviderSoap::$settings
protected

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

◆ $uri

string ilAuthProviderSoap::$uri = ''
protected

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

◆ $use_dot_net

bool ilAuthProviderSoap::$use_dot_net = false
protected

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


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