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

Description of class class. More...

+ Inheritance diagram for ilAuthFrontendCredentialsApache:
+ Collaboration diagram for ilAuthFrontendCredentialsApache:

Public Member Functions

 __construct (ServerRequestInterface $httpRequest, \ilCtrl $ctrl)
 ilAuthFrontendCredentialsApache constructor. More...
 
 tryAuthenticationOnLoginPage ()
 Check if an authentication attempt should be done when login page has been called. More...
 
 initFromRequest ()
 Init credentials from request. More...
 
 hasValidTargetUrl ()
 
 getTargetUrl ()
 
- Public Member Functions inherited from ilAuthFrontendCredentials
 __construct ()
 
 getLogger ()
 Get logger. More...
 
 setLogger (ilLogger $logger)
 Set Logger. More...
 
 setUsername ($a_name)
 Set username. More...
 
 getUsername ()
 Get username. More...
 
 setPassword ($a_password)
 Set password. More...
 
 getPassword ()
 Get password. More...
 
 setCaptchaCode ($a_code)
 Set captcha code. More...
 
 getCaptchaCode ()
 Get captcha code. More...
 
 setAuthMode ($a_auth_mode)
 Set auth mode. More...
 
 getAuthMode ()
 Get auth mode. More...
 

Protected Member Functions

 getSettings ()
 

Private Attributes

 $httpRequest
 
 $ctrl
 
 $settings = null
 

Detailed Description

Description of class class.

Author
Stefan Meyer smeye.nosp@m.r.il.nosp@m.ias@g.nosp@m.mx.d.nosp@m.e
Michael Jansen mjans.nosp@m.en@d.nosp@m.ataba.nosp@m.y.de

Definition at line 13 of file class.ilAuthFrontendCredentialsApache.php.

Constructor & Destructor Documentation

◆ __construct()

ilAuthFrontendCredentialsApache::__construct ( ServerRequestInterface  $httpRequest,
\ilCtrl  $ctrl 
)

ilAuthFrontendCredentialsApache constructor.

Parameters
ServerRequestInterface$httpRequest
\ilCtrl$ctrl

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

References $ctrl, $httpRequest, and settings().

29  {
30  $this->httpRequest = $httpRequest;
31  $this->ctrl = $ctrl;
32  parent::__construct();
33 
34  $this->settings = new \ilSetting('apache_auth');
35  }
settings()
Definition: settings.php:2
+ Here is the call graph for this function:

Member Function Documentation

◆ getSettings()

ilAuthFrontendCredentialsApache::getSettings ( )
protected
Returns

Definition at line 91 of file class.ilAuthFrontendCredentialsApache.php.

References $settings.

Referenced by initFromRequest(), and tryAuthenticationOnLoginPage().

+ Here is the caller graph for this function:

◆ getTargetUrl()

ilAuthFrontendCredentialsApache::getTargetUrl ( )
Returns
string

Definition at line 147 of file class.ilAuthFrontendCredentialsApache.php.

147  : string
148  {
149  return \ilUtil::appendUrlParameterString(trim($this->httpRequest->getQueryParams()['r']), 'passed_sso=1');
150  }

◆ hasValidTargetUrl()

ilAuthFrontendCredentialsApache::hasValidTargetUrl ( )
Returns
bool

Definition at line 122 of file class.ilAuthFrontendCredentialsApache.php.

References $path.

122  : bool
123  {
124  $targetUrl = trim((string) ($this->httpRequest->getQueryParams()['r'] ?? ''));
125  if (0 == strlen($targetUrl)) {
126  return false;
127  }
128 
129  $validDomains = array();
130  $path = ILIAS_DATA_DIR . '/' . CLIENT_ID . '/apache_auth_allowed_domains.txt';
131  if (file_exists($path) && is_readable($path)) {
132  foreach (file($path) as $line) {
133  if (trim($line)) {
134  $validDomains[] = trim($line);
135  }
136  }
137  }
138 
139  $validator = new \ilWhiteListUrlValidator($targetUrl, $validDomains);
140 
141  return $validator->isValid();
142  }
$path
Definition: aliased.php:25

◆ initFromRequest()

ilAuthFrontendCredentialsApache::initFromRequest ( )

Init credentials from request.

Definition at line 99 of file class.ilAuthFrontendCredentialsApache.php.

References ilLogLevel\DEBUG, ilAuthFrontendCredentials\getLogger(), getSettings(), ApacheCustom\getUsername(), and ilAuthFrontendCredentials\setUsername().

100  {
101  $mappingFieldName = $this->getSettings()->get('apache_auth_username_direct_mapping_fieldname', '');
102 
103  $this->getLogger()->dump($this->httpRequest->getServerParams(), \ilLogLevel::DEBUG);
104  $this->getLogger()->debug($mappingFieldName);
105 
106  switch ($this->getSettings()->get('apache_auth_username_config_type')) {
107  case \ilAuthProviderApache::APACHE_AUTH_TYPE_DIRECT_MAPPING:
108  if (isset($this->httpRequest->getServerParams()[$mappingFieldName])) {
109  $this->setUsername($this->httpRequest->getServerParams()[$mappingFieldName]);
110  }
111  break;
112 
113  case \ilAuthProviderApache::APACHE_AUTH_TYPE_BY_FUNCTION:
114  $this->setUsername((string) \ApacheCustom::getUsername());
115  break;
116  }
117  }
+ Here is the call graph for this function:

◆ tryAuthenticationOnLoginPage()

ilAuthFrontendCredentialsApache::tryAuthenticationOnLoginPage ( )

Check if an authentication attempt should be done when login page has been called.

Redirects in case no apache authentication has been tried before (GET['passed_sso'])

Definition at line 41 of file class.ilAuthFrontendCredentialsApache.php.

References $path, ilUtil\getHtmlPath(), getSettings(), IL_COOKIE_PATH, and ilContext\supportsRedirects().

42  {
43  $cmd = (string) ($this->httpRequest->getQueryParams()['cmd'] ?? '');
44  if ('' === $cmd) {
45  $cmd = (string) ($this->httpRequest->getParsedBody()['cmd'] ?? '');
46  }
47 
48  if ('force_login' === $cmd) {
49  return false;
50  }
51 
52  if (!$this->getSettings()->get('apache_enable_auth', false)) {
53  return false;
54  }
55 
56  if (!$this->getSettings()->get('apache_auth_authenticate_on_login_page', false)) {
57  return false;
58  }
59 
60  if (
62  isset($this->httpRequest->getQueryParams()['passed_sso']) ||
63  (defined('IL_CERT_SSO') && IL_CERT_SSO == '1')
64  ) {
65  return false;
66  }
67 
68  $path = (string) ($this->httpRequest->getServerParams()['REQUEST_URI'] ?? '');
69  if (substr($path, 0, 1) === '/') {
70  $path = substr($path, 1);
71  }
72 
73  if (substr($path, 0, 4) !== 'http') {
74  $parts = parse_url(ILIAS_HTTP_PATH);
75  $path = $parts['scheme'] . '://' . $parts['host'] . '/' . $path;
76  }
77 
78  $this->ctrl->redirectToURL(
80  './sso/index.php?force_mode_apache=1&' .
81  'r=' . urlencode($path) .
82  '&cookie_path=' . urlencode(IL_COOKIE_PATH) .
83  '&ilias_path=' . urlencode(ILIAS_HTTP_PATH)
84  )
85  );
86  }
$path
Definition: aliased.php:25
const IL_COOKIE_PATH(isset($_GET["client_id"]))
Definition: metadata.php:32
static getHtmlPath($relative_path)
get url of path
static supportsRedirects()
Are redirects supported?
+ Here is the call graph for this function:

Field Documentation

◆ $ctrl

ilAuthFrontendCredentialsApache::$ctrl
private

Definition at line 19 of file class.ilAuthFrontendCredentialsApache.php.

Referenced by __construct().

◆ $httpRequest

ilAuthFrontendCredentialsApache::$httpRequest
private

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

Referenced by __construct().

◆ $settings

ilAuthFrontendCredentialsApache::$settings = null
private

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

Referenced by getSettings().


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