ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilAuthProviderApache Class Reference

Apache auth provider. More...

+ Inheritance diagram for ilAuthProviderApache:
+ Collaboration diagram for ilAuthProviderApache:

Public Member Functions

 __construct (\ilAuthCredentials $credentials)
 Constructor. More...
 
 doAuthentication (\ilAuthStatus $status)
 
 migrateAccount (\ilAuthStatus $status)
 Migrate existing account Maybe ldap sync has to be performed here. More...
 
 createNewAccount (\ilAuthStatus $status)
 Create new account for account migration. More...
 
 getExternalAccountName ()
 Get external account name. More...
 
 setExternalAccountName ($a_name)
 Set external account name. More...
 
 getTriggerAuthMode ()
 Get auth mode of current authentication type. More...
 
 getUserAuthModeName ()
 Get user auth mode name. More...
 
- Public Member Functions inherited from ilAuthProvider
 __construct (ilAuthCredentials $credentials)
 Constructor. More...
 
 getLogger ()
 Get logger. More...
 
 getCredentials ()
 
- Public Member Functions inherited from ilAuthProviderAccountMigrationInterface
 migrateAccount (ilAuthStatus $status)
 Create new account. More...
 
 createNewAccount (ilAuthStatus $status)
 Create new ILIAS account for external_account. More...
 

Data Fields

const APACHE_AUTH_TYPE_DIRECT_MAPPING = 1
 
const APACHE_AUTH_TYPE_EXTENDED_MAPPING = 2
 
const APACHE_AUTH_TYPE_BY_FUNCTION = 3
 
- Data Fields inherited from ilAuthProvider
const STATUS_UNDEFINED = 0
 
const STATUS_AUTHENTICATION_SUCCESS = 1
 
const STATUS_AUTHENTICATION_FAILED = 2
 
const STATUS_MIGRATION = 3
 

Protected Member Functions

 getSettings ()
 Get setings. More...
 
 handleLDAPDataSource (ilAuthStatus $status)
 Handle ldap as data source. More...
 
- Protected Member Functions inherited from ilAuthProvider
 handleAuthenticationFail (ilAuthStatus $status, $a_reason)
 Handle failed authentication. More...
 

Private Attributes

 $settings = null
 
 $migration_account = ''
 
 $force_new_account = false
 

Detailed Description

Apache auth provider.

Author
Stefan Meyer smeye.nosp@m.r.il.nosp@m.ias@g.nosp@m.mx.d.nosp@m.e

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

Constructor & Destructor Documentation

◆ __construct()

ilAuthProviderApache::__construct ( \ilAuthCredentials  $credentials)

Constructor.

Parameters
\ilAuthCredentials$credentials

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

References settings().

31  {
32  parent::__construct($credentials);
33 
34  include_once './Services/Administration/classes/class.ilSetting.php';
35  $this->settings = new ilSetting('apache_auth');
36  }
settings()
Definition: settings.php:2
+ Here is the call graph for this function:

Member Function Documentation

◆ createNewAccount()

ilAuthProviderApache::createNewAccount ( \ilAuthStatus  $status)

Create new account for account migration.

Parameters
\ilAuthStatus$status

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

References getSettings(), and handleLDAPDataSource().

130  {
131  $this->force_new_account = true;
132  if ($this->getSettings()->get('apache_enable_ldap')) {
133  return $this->handleLDAPDataSource($status);
134  }
135  }
handleLDAPDataSource(ilAuthStatus $status)
Handle ldap as data source.
+ Here is the call graph for this function:

◆ doAuthentication()

ilAuthProviderApache::doAuthentication ( \ilAuthStatus  $status)
Parameters
\ilAuthStatus$status
Returns
bool

Implements ilAuthProviderInterface.

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

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

52  {
53  if (!$this->getSettings()->get('apache_enable_auth')) {
54  $this->getLogger()->info('Apache auth disabled.');
55  $this->handleAuthenticationFail($status, 'apache_auth_err_disabled');
56  return false;
57  }
58 
59  if (
60  !$this->getSettings()->get('apache_auth_indicator_name') ||
61  !$this->getSettings()->get('apache_auth_indicator_value')
62  ) {
63  $this->getLogger()->warning('Apache auth indicator match failure.');
64  $this->handleAuthenticationFail($status, 'apache_auth_err_indicator_match_failure');
65  return false;
66  }
67 
68  if (
69  !in_array(
70  $_SERVER[$this->getSettings()->get('apache_auth_indicator_name')],
71  array_filter(array_map('trim', str_getcsv($this->getSettings()->get('apache_auth_indicator_value'))))
72  )
73  ) {
74  $this->getLogger()->warning('Apache authentication failed (indicator name <-> value');
75  $this->handleAuthenticationFail($status, 'err_wrong_login');
76  return false;
77  }
78 
79  include_once './Services/Utilities/classes/class.ilUtil.php';
80  if (!ilUtil::isLogin($this->getCredentials()->getUsername())) {
81  $this->getLogger()->warning('Invalid login name given: ' . $this->getCredentials()->getUsername());
82  $this->handleAuthenticationFail($status, 'apache_auth_err_invalid_login');
83  return false;
84  }
85 
86  if (!strlen($this->getCredentials()->getUsername())) {
87  $this->getLogger()->info('No username given');
88  $this->handleAuthenticationFail($status, 'err_wrong_login');
89  return false;
90  }
91 
92  // Apache with ldap as data source
93  include_once './Services/LDAP/classes/class.ilLDAPServer.php';
94  if ($this->getSettings()->get('apache_enable_ldap')) {
95  return $this->handleLDAPDataSource($status);
96  }
97 
98  $login = ilObjUser::_checkExternalAuthAccount('apache', $this->getCredentials()->getUsername());
99  $usr_id = ilObjUser::_lookupId($login);
100  if (!$usr_id) {
101  $this->getLogger()->info('Cannot find user id for external account: ' . $this->getCredentials()->getUsername());
102  $this->handleAuthenticationFail($status, 'err_wrong_login');
103  return false;
104  }
105 
107  $status->setAuthenticatedUserId($usr_id);
108  return true;
109  }
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
handleLDAPDataSource(ilAuthStatus $status)
Handle ldap as data source.
static _lookupId($a_user_str)
Lookup id by login.
static _checkExternalAuthAccount($a_auth, $a_account, $tryFallback=true)
check whether external account and authentication method matches with a user
getLogger()
Get logger.
static isLogin($a_login)
handleAuthenticationFail(ilAuthStatus $status, $a_reason)
Handle failed authentication.
$login
Definition: cron.php:13
+ Here is the call graph for this function:

◆ getExternalAccountName()

ilAuthProviderApache::getExternalAccountName ( )

Get external account name.

Returns
string

Implements ilAuthProviderAccountMigrationInterface.

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

References $migration_account.

◆ getSettings()

ilAuthProviderApache::getSettings ( )
protected

Get setings.

Returns

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

References $settings.

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

+ Here is the caller graph for this function:

◆ getTriggerAuthMode()

ilAuthProviderApache::getTriggerAuthMode ( )

Get auth mode of current authentication type.

Implements ilAuthProviderAccountMigrationInterface.

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

References AUTH_APACHE.

159  {
160  return AUTH_APACHE;
161  }
const AUTH_APACHE

◆ getUserAuthModeName()

ilAuthProviderApache::getUserAuthModeName ( )

Get user auth mode name.

Implements ilAuthProviderAccountMigrationInterface.

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

References getSettings().

167  {
168  if ($this->getSettings()->get('apache_ldap_sid')) {
169  return 'ldap_' . (string) $this->getSettings()->get('apache_ldap_sid');
170  }
171  return 'apache';
172  }
+ Here is the call graph for this function:

◆ handleLDAPDataSource()

ilAuthProviderApache::handleLDAPDataSource ( ilAuthStatus  $status)
protected

Handle ldap as data source.

Parameters
Auth$auth
string$ext_account

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

References $server, $sync, ilObjUser\_lookupId(), ilAuthProvider\getCredentials(), ilLDAPServer\getInstanceByServerId(), ilAuthProvider\getLogger(), getSettings(), ilAuthProvider\handleAuthenticationFail(), ilAuthStatus\setAuthenticatedUserId(), setExternalAccountName(), ilAuthStatus\setStatus(), ilAuthStatus\STATUS_ACCOUNT_MIGRATION_REQUIRED, and ilAuthStatus\STATUS_AUTHENTICATED.

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

180  {
181  include_once './Services/LDAP/classes/class.ilLDAPServer.php';
183  $this->getSettings()->get('apache_ldap_sid')
184  );
185 
186  $this->getLogger()->debug('Using ldap data source with server configuration: ' . $server->getName());
187 
188  include_once './Services/LDAP/classes/class.ilLDAPUserSynchronisation.php';
189  $sync = new ilLDAPUserSynchronisation('ldap_' . $server->getServerId(), $server->getServerId());
190  $sync->setExternalAccount($this->getCredentials()->getUsername());
191  $sync->setUserData(array());
192  $sync->forceCreation($this->force_new_account);
193  $sync->forceReadLdapData(true);
194 
195  try {
196  $internal_account = $sync->sync();
197  $this->getLogger()->debug('Internal account: ' . $internal_account);
198  } catch (UnexpectedValueException $e) {
199  $this->getLogger()->info('Login failed with message: ' . $e->getMessage());
200  $this->handleAuthenticationFail($status, 'err_wrong_login');
201  return false;
203  // No syncronisation allowed => create Error
204  $this->getLogger()->info('Login failed with message: ' . $e->getMessage());
205  $this->handleAuthenticationFail($status, 'err_auth_ldap_no_ilias_user');
206  return false;
208  // Account migration required
209  $this->setExternalAccountName($this->getCredentials()->getUsername());
210  $this->getLogger()->info('Authentication failed: account migration required for external account: ' . $this->getCredentials()->getUsername());
212  return false;
213  }
215  $status->setAuthenticatedUserId(ilObjUser::_lookupId($internal_account));
216  return true;
217  }
Synchronization of user accounts used in auth container ldap, radius , cas,...
static _lookupId($a_user_str)
Lookup id by login.
Description of ilLDAPAccountMigrationRequiredException.
$server
Definition: sabredav.php:48
static getInstanceByServerId($a_server_id)
Get instance by server id.
setAuthenticatedUserId($a_id)
setStatus($a_status)
Set auth status.
$sync
getLogger()
Get logger.
handleAuthenticationFail(ilAuthStatus $status, $a_reason)
Handle failed authentication.
setExternalAccountName($a_name)
Set external account name.
const STATUS_ACCOUNT_MIGRATION_REQUIRED
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ migrateAccount()

ilAuthProviderApache::migrateAccount ( \ilAuthStatus  $status)

Migrate existing account Maybe ldap sync has to be performed here.

Parameters
ilAuthStatus$status
int$a_usr_id

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

References getSettings(), and handleLDAPDataSource().

118  {
119  $this->force_new_account = true;
120  if ($this->getSettings()->get('apache_enable_ldap')) {
121  return $this->handleLDAPDataSource($status);
122  }
123  }
handleLDAPDataSource(ilAuthStatus $status)
Handle ldap as data source.
+ Here is the call graph for this function:

◆ setExternalAccountName()

ilAuthProviderApache::setExternalAccountName (   $a_name)

Set external account name.

Parameters
string$a_name

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

Referenced by handleLDAPDataSource().

151  {
152  $this->migration_account = $a_name;
153  }
+ Here is the caller graph for this function:

Field Documentation

◆ $force_new_account

ilAuthProviderApache::$force_new_account = false
private

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

◆ $migration_account

ilAuthProviderApache::$migration_account = ''
private

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

Referenced by getExternalAccountName().

◆ $settings

ilAuthProviderApache::$settings = null
private

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

Referenced by getSettings().

◆ APACHE_AUTH_TYPE_BY_FUNCTION

const ilAuthProviderApache::APACHE_AUTH_TYPE_BY_FUNCTION = 3

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

◆ APACHE_AUTH_TYPE_DIRECT_MAPPING

const ilAuthProviderApache::APACHE_AUTH_TYPE_DIRECT_MAPPING = 1

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

◆ APACHE_AUTH_TYPE_EXTENDED_MAPPING

const ilAuthProviderApache::APACHE_AUTH_TYPE_EXTENDED_MAPPING = 2

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


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