ILIAS  release_8 Revision v8.24
ilAuthProviderSoap Class Reference

Class ilAuthProviderSoap. More...

+ Inheritance diagram for ilAuthProviderSoap:
+ Collaboration diagram for ilAuthProviderSoap:

Public Member Functions

 __construct (ilAuthCredentials $credentials)
 Constructor. More...
 
 doAuthentication (ilAuthStatus $status)
 @inheritDoc More...
 
- 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

Class ilAuthProviderSoap.

Author
Michael Jansen mjans.nosp@m.en@d.nosp@m.ataba.nosp@m.y.de

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

Constructor & Destructor Documentation

◆ __construct()

ilAuthProviderSoap::__construct ( ilAuthCredentials  $credentials)

Constructor.

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
49 }
ilAuthCredentials $credentials
global $DIC
Definition: feed.php:28
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

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

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

77 : bool
78 {
79 try {
80 $this->initClient();
81 $this->handleSoapAuth($status);
82 } catch (Exception $e) {
83 $this->getLogger()->error($e->getMessage());
84 $status->setTranslatedReason($e->getMessage());
85 }
86
87 if ($status->getAuthenticatedUserId() > 0 && $status->getAuthenticatedUserId() !== ANONYMOUS_USER_ID) {
88 $this->logger->info('Successfully authenticated user via SOAP: ' . $this->getCredentials()->getUsername());
90 ilSession::set('used_external_auth', true);
91
92 return true;
93 }
94
96
97 return false;
98 }
handleSoapAuth(ilAuthStatus $status)
getLogger()
Get logger.
const STATUS_AUTHENTICATION_FAILED
static set(string $a_var, $a_val)
Set a value.
const ANONYMOUS_USER_ID
Definition: constants.php:27

References Vendor\Package\$e, ilAuthProvider\$status, ANONYMOUS_USER_ID, ilAuthProvider\getCredentials(), ilAuthProvider\getLogger(), handleSoapAuth(), initClient(), ILIAS\Repository\logger(), ilSession\set(), 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 100 of file class.ilAuthProviderSoap.php.

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

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

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

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

References $server_host, $server_port, $server_uri, 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 33 of file class.ilAuthProviderSoap.php.

◆ $language

ilLanguage ilAuthProviderSoap::$language
protected

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

◆ $logger

ilLogger ilAuthProviderSoap::$logger
protected

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

◆ $rbacAdmin

ilRbacAdmin ilAuthProviderSoap::$rbacAdmin
protected

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

◆ $server_host

string ilAuthProviderSoap::$server_host = ''
protected

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

Referenced by initClient().

◆ $server_https

bool ilAuthProviderSoap::$server_https = false
protected

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

◆ $server_nms

string ilAuthProviderSoap::$server_nms = ''
protected

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

◆ $server_port

string ilAuthProviderSoap::$server_port = ''
protected

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

Referenced by initClient().

◆ $server_uri

string ilAuthProviderSoap::$server_uri = ''
protected

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

Referenced by initClient().

◆ $settings

ilSetting ilAuthProviderSoap::$settings
protected

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

◆ $uri

string ilAuthProviderSoap::$uri = ''
protected

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

◆ $use_dot_net

bool ilAuthProviderSoap::$use_dot_net = false
protected

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


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