ILIAS  trunk Revision v12.0_alpha-1540-g00f839d5fa1
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
87 $this->handleAuthenticationFail($status, 'err_wrong_login');
88
89 return false;
90 }
91
92 if ($status->getAuthenticatedUserId() > 0 && $status->getAuthenticatedUserId() !== ANONYMOUS_USER_ID) {
93 $this->logger->info('Successfully authenticated user via SOAP: ' . $this->getCredentials()->getUsername());
95 ilSession::set('used_external_auth_mode', ilAuthUtils::AUTH_SOAP);
96
97 return true;
98 }
99
100 $this->handleAuthenticationFail($status, 'err_wrong_login');
101
102 return false;
103 }
handleSoapAuth(ilAuthStatus $status)
handleAuthenticationFail(ilAuthStatus $status, string $a_reason)
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(), ilAuthProvider\handleAuthenticationFail(), handleSoapAuth(), initClient(), ILIAS\Repository\logger(), ilSession\set(), ilAuthStatus\setStatus(), and ilAuthStatus\STATUS_AUTHENTICATED.

+ Here is the call graph for this function:

◆ handleSoapAuth()

ilAuthProviderSoap::handleSoapAuth ( ilAuthStatus  $status)
private

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

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

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: