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

Public Member Functions

 __construct (ilAuthCredentials $credentials)
 
 doAuthentication (ilAuthStatus $status)
 
 migrateAccount (ilAuthStatus $status)
 Create new account. More...
 
 createNewAccount (ilAuthStatus $status)
 Create new ILIAS account for external_account. More...
 
 getExternalAccountName ()
 Get external account name. More...
 
 setExternalAccountName (string $name)
 
 getTriggerAuthMode ()
 Get auth mode which triggered the account migration 2_1 for ldap account migration with server id 1 11 for apache auth. More...
 
 getUserAuthModeName ()
 Get user auth mode name ldap_1 for ldap account migration with server id 1 apache for apache auth. More...
 
- Public Member Functions inherited from ilAuthProvider
 __construct (ilAuthCredentials $credentials)
 
 getLogger ()
 
 getCredentials ()
 
 doAuthentication (ilAuthStatus $status)
 
 getTriggerAuthMode ()
 Get auth mode which triggered the account migration 2_1 for ldap account migration with server id 1 11 for apache auth. More...
 
 getUserAuthModeName ()
 Get user auth mode name ldap_1 for ldap account migration with server id 1 apache for apache auth. More...
 
 getExternalAccountName ()
 Get external account name. More...
 
 migrateAccount (ilAuthStatus $status)
 Create new account. More...
 
 createNewAccount (ilAuthStatus $status)
 Create new ILIAS account for external_account. More...
 

Data Fields

const int APACHE_AUTH_TYPE_DIRECT_MAPPING = 1
 
const int APACHE_AUTH_TYPE_EXTENDED_MAPPING = 2
 
const int APACHE_AUTH_TYPE_BY_FUNCTION = 3
 

Private Member Functions

 handleLDAPDataSource (ilAuthStatus $status)
 

Private Attributes

const string ENV_APACHE_AUTH_INDICATOR_NAME = 'apache_auth_indicator_name'
 
const string ERR_WRONG_LOGIN = 'err_wrong_login'
 
const string APACHE_ENABLE_LDAP = 'apache_enable_ldap'
 
const string APACHE_LDAP_SID = 'apache_ldap_sid'
 
readonly ilSetting $settings
 
string $migration_account = ''
 
bool $force_new_account = false
 

Additional Inherited Members

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

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

ilAuthProviderApache::__construct ( ilAuthCredentials  $credentials)

Reimplemented from ilAuthProvider.

Definition at line 38 of file class.ilAuthProviderApache.php.

39 {
41 $this->settings = new ilSetting('apache_auth');
42 }
ilAuthCredentials $credentials
ILIAS Setting Class.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

References ilAuthProvider\$credentials, ILIAS\GlobalScreen\Provider\__construct(), and ILIAS\Repository\settings().

+ Here is the call graph for this function:

Member Function Documentation

◆ createNewAccount()

ilAuthProviderApache::createNewAccount ( ilAuthStatus  $status)

Create new ILIAS account for external_account.

Implements ilAuthProviderAccountMigrationInterface.

Definition at line 113 of file class.ilAuthProviderApache.php.

113 : void
114 {
115 $this->force_new_account = true;
116 if ($this->settings->get(self::APACHE_ENABLE_LDAP, '0')) {
117 $this->handleLDAPDataSource($status);
118 }
119 }
handleLDAPDataSource(ilAuthStatus $status)

References handleLDAPDataSource(), and ILIAS\Repository\settings().

+ Here is the call graph for this function:

◆ doAuthentication()

ilAuthProviderApache::doAuthentication ( ilAuthStatus  $status)

Implements ilAuthProviderInterface.

Definition at line 44 of file class.ilAuthProviderApache.php.

44 : bool
45 {
46 if (!$this->settings->get('apache_enable_auth', '0')) {
47 $this->getLogger()->info('Apache auth disabled.');
48 $this->handleAuthenticationFail($status, 'apache_auth_err_disabled');
49 return false;
50 }
51
52 if (
53 !$this->settings->get(self::ENV_APACHE_AUTH_INDICATOR_NAME, '') ||
54 !$this->settings->get('apache_auth_indicator_value', '')
55 ) {
56 $this->getLogger()->warning('Apache auth indicator match failure.');
57 $this->handleAuthenticationFail($status, 'apache_auth_err_indicator_match_failure');
58 return false;
59 }
60
61 $validIndicatorValues = array_filter(array_map(
62 'trim',
63 str_getcsv($this->settings->get('apache_auth_indicator_value', ''), ',', '"', '\\')
64 ));
65 //TODO PHP8-REVIEW: $DIC->http()->request()->getServerParams()['apache_auth_indicator_name']
66 if (
67 !isset($_SERVER[$this->settings->get(self::ENV_APACHE_AUTH_INDICATOR_NAME, '')]) ||
68 !in_array($_SERVER[$this->settings->get(self::ENV_APACHE_AUTH_INDICATOR_NAME, '')], $validIndicatorValues, true)
69 ) {
70 $this->getLogger()->warning('Apache authentication failed (indicator name <-> value');
71 $this->handleAuthenticationFail($status, self::ERR_WRONG_LOGIN);
72 return false;
73 }
74
75 if (!ilUtil::isLogin($this->getCredentials()->getUsername())) {
76 $this->getLogger()->warning('Invalid login name given: ' . $this->getCredentials()->getUsername());
77 $this->handleAuthenticationFail($status, 'apache_auth_err_invalid_login');
78 return false;
79 }
80
81 if ($this->getCredentials()->getUsername() === '') {
82 $this->getLogger()->info('No username given');
83 $this->handleAuthenticationFail($status, self::ERR_WRONG_LOGIN);
84 return false;
85 }
86
87 // Apache with ldap as data source
88 if ($this->settings->get(self::APACHE_ENABLE_LDAP, '0')) {
89 return $this->handleLDAPDataSource($status);
90 }
91
92 $login = ilObjUser::_checkExternalAuthAccount('apache', $this->getCredentials()->getUsername());
93 $usr_id = ilObjUser::_lookupId($login);
94 if (!$usr_id) {
95 $this->getLogger()->info('Cannot find user id for external account: ' . $this->getCredentials()->getUsername());
96 $this->handleAuthenticationFail($status, self::ERR_WRONG_LOGIN);
97 return false;
98 }
99
101 $status->setAuthenticatedUserId($usr_id);
102 return true;
103 }
handleAuthenticationFail(ilAuthStatus $status, string $a_reason)
setAuthenticatedUserId(int $a_id)
setStatus(int $a_status)
Set auth status.
const int STATUS_AUTHENTICATED
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
static isLogin(string $a_login)
$_SERVER['HTTP_HOST']
Definition: raiseError.php:26

References $_SERVER, ilObjUser\_checkExternalAuthAccount(), ilObjUser\_lookupId(), ilAuthProvider\getCredentials(), ilAuthProvider\getLogger(), ilAuthProvider\handleAuthenticationFail(), handleLDAPDataSource(), ilUtil\isLogin(), ilAuthStatus\setAuthenticatedUserId(), ilAuthStatus\setStatus(), ILIAS\Repository\settings(), and ilAuthStatus\STATUS_AUTHENTICATED.

+ Here is the call graph for this function:

◆ getExternalAccountName()

ilAuthProviderApache::getExternalAccountName ( )

Get external account name.

Implements ilAuthProviderAccountMigrationInterface.

Definition at line 121 of file class.ilAuthProviderApache.php.

121 : string
122 {
124 }

References $migration_account.

◆ getTriggerAuthMode()

ilAuthProviderApache::getTriggerAuthMode ( )

Get auth mode which triggered the account migration 2_1 for ldap account migration with server id 1 11 for apache auth.

See also
ilAuthUtils

Implements ilAuthProviderAccountMigrationInterface.

Definition at line 131 of file class.ilAuthProviderApache.php.

131 : string
132 {
133 return (string) ilAuthUtils::AUTH_APACHE;
134 }
const int AUTH_APACHE

References ilAuthUtils\AUTH_APACHE.

◆ getUserAuthModeName()

ilAuthProviderApache::getUserAuthModeName ( )

Get user auth mode name ldap_1 for ldap account migration with server id 1 apache for apache auth.

Implements ilAuthProviderAccountMigrationInterface.

Definition at line 136 of file class.ilAuthProviderApache.php.

136 : string
137 {
138 if ($this->settings->get(self::APACHE_LDAP_SID, '0')) {
139 return 'ldap_' . $this->settings->get(self::APACHE_LDAP_SID, '');
140 }
141
142 return 'apache';
143 }

References ILIAS\Repository\settings().

+ Here is the call graph for this function:

◆ handleLDAPDataSource()

ilAuthProviderApache::handleLDAPDataSource ( ilAuthStatus  $status)
private

Definition at line 145 of file class.ilAuthProviderApache.php.

145 : bool
146 {
148 (int) $this->settings->get(self::APACHE_LDAP_SID, '0')
149 );
150
151 $this->getLogger()->debug('Using ldap data source with server configuration: ' . $server->getName());
152
153 $sync = new ilLDAPUserSynchronisation('ldap_' . $server->getServerId(), $server->getServerId());
154 $sync->setExternalAccount($this->getCredentials()->getUsername());
155 $sync->setUserData([]);
156 $sync->forceCreation($this->force_new_account);
157 $sync->forceReadLdapData(true);
158
159 try {
160 $internal_account = $sync->sync();
161 $this->getLogger()->debug('Internal account: ' . $internal_account);
162 } catch (UnexpectedValueException $e) {
163 $this->getLogger()->info('Login failed with message: ' . $e->getMessage());
164 $this->handleAuthenticationFail($status, self::ERR_WRONG_LOGIN);
165 return false;
167 $this->handleAuthenticationFail($status, 'err_auth_ldap_failed');
168 return false;
170 $this->getLogger()->info('Login failed with message: ' . $e->getMessage());
171 $this->handleAuthenticationFail($status, 'err_auth_ldap_no_ilias_user');
172 return false;
174 $this->setExternalAccountName($this->getCredentials()->getUsername());
175 $this->getLogger()->info('Authentication failed: account migration required for external account: ' . $this->getCredentials()->getUsername());
177 return false;
178 }
179
181 $status->setAuthenticatedUserId(ilObjUser::_lookupId($internal_account));
182 return true;
183 }
const int STATUS_ACCOUNT_MIGRATION_REQUIRED
static getInstanceByServerId(int $a_server_id)
Get instance by server id.
Thrown in case of failed synchronisation settings.
Synchronization of user accounts used in auth container ldap, ,...
$server
Definition: shib_login.php:28

References Vendor\Package\$e, $server, ilObjUser\_lookupId(), ilAuthProvider\getCredentials(), ilLDAPServer\getInstanceByServerId(), ilAuthProvider\getLogger(), ilAuthProvider\handleAuthenticationFail(), ilAuthStatus\setAuthenticatedUserId(), setExternalAccountName(), ilAuthStatus\setStatus(), ILIAS\Repository\settings(), ilAuthStatus\STATUS_ACCOUNT_MIGRATION_REQUIRED, and ilAuthStatus\STATUS_AUTHENTICATED.

Referenced by createNewAccount(), doAuthentication(), and migrateAccount().

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

◆ migrateAccount()

ilAuthProviderApache::migrateAccount ( ilAuthStatus  $status)

Create new account.

Implements ilAuthProviderAccountMigrationInterface.

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

105 : void
106 {
107 $this->force_new_account = true;
108 if ($this->settings->get(self::APACHE_ENABLE_LDAP, '0')) {
109 $this->handleLDAPDataSource($status);
110 }
111 }

References handleLDAPDataSource(), and ILIAS\Repository\settings().

+ Here is the call graph for this function:

◆ setExternalAccountName()

ilAuthProviderApache::setExternalAccountName ( string  $name)

Definition at line 126 of file class.ilAuthProviderApache.php.

126 : void
127 {
128 $this->migration_account = $name;
129 }

Referenced by handleLDAPDataSource().

+ Here is the caller graph for this function:

Field Documentation

◆ $force_new_account

bool ilAuthProviderApache::$force_new_account = false
private

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

◆ $migration_account

string ilAuthProviderApache::$migration_account = ''
private

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

Referenced by getExternalAccountName().

◆ $settings

readonly ilSetting ilAuthProviderApache::$settings
private

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

◆ APACHE_AUTH_TYPE_BY_FUNCTION

const int ilAuthProviderApache::APACHE_AUTH_TYPE_BY_FUNCTION = 3

◆ APACHE_AUTH_TYPE_DIRECT_MAPPING

const int ilAuthProviderApache::APACHE_AUTH_TYPE_DIRECT_MAPPING = 1

◆ APACHE_AUTH_TYPE_EXTENDED_MAPPING

const int ilAuthProviderApache::APACHE_AUTH_TYPE_EXTENDED_MAPPING = 2

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

◆ APACHE_ENABLE_LDAP

const string ilAuthProviderApache::APACHE_ENABLE_LDAP = 'apache_enable_ldap'
private

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

◆ APACHE_LDAP_SID

const string ilAuthProviderApache::APACHE_LDAP_SID = 'apache_ldap_sid'
private

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

◆ ENV_APACHE_AUTH_INDICATOR_NAME

const string ilAuthProviderApache::ENV_APACHE_AUTH_INDICATOR_NAME = 'apache_auth_indicator_name'
private

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

◆ ERR_WRONG_LOGIN

const string ilAuthProviderApache::ERR_WRONG_LOGIN = 'err_wrong_login'
private

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


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