ILIAS  trunk Revision v11.0_alpha-1769-g99a433fe2dc
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilAuthFrontendCredentialsApache Class Reference

Description of class class. More...

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

Public Member Functions

 __construct (ServerRequestInterface $httpRequest, ilCtrlInterface $ctrl)
 
 tryAuthenticationOnLoginPage ()
 Check if an authentication attempt should be done when login page has been called. More...
 
 initFromRequest ()
 
 hasValidTargetUrl ()
 
 getTargetUrl ()
 
- Public Member Functions inherited from ilAuthFrontendCredentials
 __construct ()
 
 setUsername (string $a_name)
 Set username. More...
 
 getUsername ()
 Get username. More...
 
 setPassword (string $a_password)
 Set password. More...
 
 getPassword ()
 Get password. More...
 
 setAuthMode (string $a_auth_mode)
 Set auth mode. More...
 
 getAuthMode ()
 Get auth mode. More...
 

Protected Member Functions

 getSettings ()
 

Private Attributes

ServerRequestInterface $httpRequest
 
ilCtrlInterface $ctrl
 
ilSetting $settings
 
ilLogger $logger
 

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 30 of file class.ilAuthFrontendCredentialsApache.php.

Constructor & Destructor Documentation

◆ __construct()

ilAuthFrontendCredentialsApache::__construct ( ServerRequestInterface  $httpRequest,
ilCtrlInterface  $ctrl 
)

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

References $ctrl, $DIC, $httpRequest, ILIAS\GlobalScreen\Provider\__construct(), ILIAS\Repository\ctrl(), ILIAS\Repository\logger(), and ILIAS\Repository\settings().

38  {
39  global $DIC;
40  $this->logger = $DIC->logger()->auth();
41  $this->httpRequest = $httpRequest;
42  $this->ctrl = $ctrl;
43  $this->settings = new ilSetting('apache_auth');
45  }
global $DIC
Definition: shib_login.php:22
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ getSettings()

ilAuthFrontendCredentialsApache::getSettings ( )
protected

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

References $settings.

Referenced by initFromRequest(), and tryAuthenticationOnLoginPage().

+ Here is the caller graph for this function:

◆ getTargetUrl()

ilAuthFrontendCredentialsApache::getTargetUrl ( )

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

References ilUtil\appendUrlParameterString().

143  : string
144  {
145  return ilUtil::appendUrlParameterString(trim($this->httpRequest->getQueryParams()['r']), 'passed_sso=1');
146  }
static appendUrlParameterString(string $a_url, string $a_par, bool $xml_style=false)
+ Here is the call graph for this function:

◆ hasValidTargetUrl()

ilAuthFrontendCredentialsApache::hasValidTargetUrl ( )

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

References $path, CLIENT_ID, and ILIAS_DATA_DIR.

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

◆ initFromRequest()

ilAuthFrontendCredentialsApache::initFromRequest ( )

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

References ilAuthProviderApache\APACHE_AUTH_TYPE_BY_FUNCTION, ilAuthProviderApache\APACHE_AUTH_TYPE_DIRECT_MAPPING, ilLogLevel\DEBUG, getSettings(), ApacheCustom\getUsername(), ILIAS\Repository\logger(), and ilAuthFrontendCredentials\setUsername().

103  : void
104  {
105  $mappingFieldName = $this->getSettings()->get('apache_auth_username_direct_mapping_fieldname', '');
106 
107  $this->logger->dump($this->httpRequest->getServerParams(), ilLogLevel::DEBUG);
108  $this->logger->debug($mappingFieldName);
109 
110  switch ($this->getSettings()->get('apache_auth_username_config_type')) {
112  if (isset($this->httpRequest->getServerParams()[$mappingFieldName])) {
113  $this->setUsername($this->httpRequest->getServerParams()[$mappingFieldName]);
114  }
115  break;
116 
119  break;
120  }
121  }
setUsername(string $a_name)
Set username.
+ 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 51 of file class.ilAuthFrontendCredentialsApache.php.

References $parts, $path, ILIAS\Repository\ctrl(), ilUtil\getHtmlPath(), getSettings(), IL_COOKIE_PATH, and ilContext\supportsRedirects().

51  : void
52  {
53  $cmd = (string) ($this->httpRequest->getQueryParams()['cmd'] ?? '');
54  if ('' === $cmd) {
55  $cmd = (string) ($this->httpRequest->getParsedBody()['cmd'] ?? '');
56  }
57 
58  if ('force_login' === $cmd) {
59  return;
60  }
61 
62  if (!$this->getSettings()->get('apache_enable_auth', '0')) {
63  return;
64  }
65 
66  if (!$this->getSettings()->get('apache_auth_authenticate_on_login_page', '0')) {
67  return;
68  }
69 
70  if (
71  (defined('IL_CERT_SSO') && (int) IL_CERT_SSO === 1) ||
73  isset($this->httpRequest->getQueryParams()['passed_sso'])
74  ) {
75  return;
76  }
77 
78  $path = (string) ($this->httpRequest->getServerParams()['REQUEST_URI'] ?? '');
79  if (strpos($path, '/') === 0) {
80  $path = substr($path, 1);
81  }
82 
83  if (strpos($path, 'http') !== 0) {
84  $parts = parse_url(ILIAS_HTTP_PATH);
85  $path = $parts['scheme'] . '://' . $parts['host'] . '/' . $path;
86  }
87 
88  $this->ctrl->redirectToURL(
90  './public/sso/index.php?force_mode_apache=1&' .
91  'r=' . urlencode($path) .
92  '&cookie_path=' . urlencode(IL_COOKIE_PATH) .
93  '&ilias_path=' . urlencode(ILIAS_HTTP_PATH)
94  )
95  );
96  }
if($clientAssertionType !='urn:ietf:params:oauth:client-assertion-type:jwt-bearer'|| $grantType !='client_credentials') $parts
Definition: ltitoken.php:61
$path
Definition: ltiservices.php:29
static getHtmlPath(string $relative_path)
get url of path
const IL_COOKIE_PATH(isset($_GET['client_id']))
Definition: index.php:47
static supportsRedirects()
Are redirects supported?
+ Here is the call graph for this function:

Field Documentation

◆ $ctrl

ilCtrlInterface ilAuthFrontendCredentialsApache::$ctrl
private

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

Referenced by __construct().

◆ $httpRequest

ServerRequestInterface ilAuthFrontendCredentialsApache::$httpRequest
private

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

Referenced by __construct().

◆ $logger

ilLogger ilAuthFrontendCredentialsApache::$logger
private

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

◆ $settings

ilSetting ilAuthFrontendCredentialsApache::$settings
private

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

Referenced by getSettings().


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