ILIAS  trunk Revision v12.0_alpha-1221-g4e438232683
ILIAS\AuthApache\AuthFrontendCredentialsApache Class Reference
+ Inheritance diagram for ILIAS\AuthApache\AuthFrontendCredentialsApache:
+ Collaboration diagram for ILIAS\AuthApache\AuthFrontendCredentialsApache:

Public Member Functions

 __construct (private readonly GlobalHttpState $http, private readonly Factory $refinery, private readonly 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)
 
 getUsername ()
 
 setPassword (string $a_password)
 
 getPassword ()
 
 setAuthMode (string $a_auth_mode)
 
 getAuthMode ()
 
 setUsername (string $a_name)
 
 getUsername ()
 
 setPassword (string $a_password)
 
 getPassword ()
 
 setAuthMode (string $a_auth_mode)
 
 getAuthMode ()
 

Protected Member Functions

 getSettings ()
 

Private Attributes

readonly ilSetting $settings
 

Additional Inherited Members

- Protected Attributes inherited from ilAuthFrontendCredentials
ilLogger $logger
 

Detailed Description

Definition at line 35 of file AuthFrontendCredentialsApache.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\AuthApache\AuthFrontendCredentialsApache::__construct ( private readonly GlobalHttpState  $http,
private readonly Factory  $refinery,
private readonly ilCtrlInterface  $ctrl 
)

Definition at line 39 of file AuthFrontendCredentialsApache.php.

43 {
44 $this->settings = new ilSetting('apache_auth');
46 }
ILIAS Setting Class.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

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

+ Here is the call graph for this function:

Member Function Documentation

◆ getSettings()

ILIAS\AuthApache\AuthFrontendCredentialsApache::getSettings ( )
protected

◆ getTargetUrl()

ILIAS\AuthApache\AuthFrontendCredentialsApache::getTargetUrl ( )

Definition at line 151 of file AuthFrontendCredentialsApache.php.

151 : string
152 {
153 $target_url = trim($this->http->wrapper()->query()->retrieve('r', $this->refinery->kindlyTo()->string()));
154
155 return ilUtil::appendUrlParameterString($target_url, 'passed_sso=1');
156 }
static appendUrlParameterString(string $a_url, string $a_par, bool $xml_style=false)
static http()
Fetches the global http state from ILIAS.

References ilUtil\appendUrlParameterString(), and ILIAS\FileDelivery\http().

+ Here is the call graph for this function:

◆ hasValidTargetUrl()

ILIAS\AuthApache\AuthFrontendCredentialsApache::hasValidTargetUrl ( )

Definition at line 126 of file AuthFrontendCredentialsApache.php.

126 : bool
127 {
128 $target_url = trim(
129 $this->http->wrapper()->query()->retrieve('r', $this->refinery->byTrying([
130 $this->refinery->kindlyTo()->string(),
131 $this->refinery->always(''),
132 ]))
133 );
134 if ($target_url === '') {
135 return false;
136 }
137
138 $valid_hosts = [];
139 $path = ILIAS_DATA_DIR . '/' . CLIENT_ID . '/apache_auth_allowed_domains.txt';
140 if (file_exists($path) && is_readable($path)) {
141 foreach (file($path) as $line) {
142 if (trim($line)) {
143 $valid_hosts[] = trim($line);
144 }
145 }
146 }
147
148 return (new WhiteListUrlValidator($target_url, $valid_hosts))->isValid();
149 }
const CLIENT_ID
Definition: constants.php:41
const ILIAS_DATA_DIR
Definition: constants.php:44
$path
Definition: ltiservices.php:30

References $path, CLIENT_ID, ILIAS\FileDelivery\http(), and ILIAS_DATA_DIR.

+ Here is the call graph for this function:

◆ initFromRequest()

ILIAS\AuthApache\AuthFrontendCredentialsApache::initFromRequest ( )

Definition at line 101 of file AuthFrontendCredentialsApache.php.

101 : void
102 {
103 $mapping_field_name = $this->getSettings()->get('apache_auth_username_direct_mapping_fieldname', '');
104
105 $this->logger->dump($this->http->request()->getServerParams(), ilLogLevel::DEBUG);
106 $this->logger->debug($mapping_field_name);
107
108 switch ($this->getSettings()->get('apache_auth_username_config_type')) {
110 if (isset($this->http->request()->getServerParams()[$mapping_field_name])) {
111 $this->setUsername($this->http->request()->getServerParams()[$mapping_field_name]);
112 }
113 break;
114
116 $factory = new UsernameProviderFactory();
117 $resolver = new UsernameResolver($factory->fromClassNames(
118 require CollectUsernameProvidersObjective::PATH()
119 ), $this->logger);
120
121 $this->setUsername($resolver->resolve($this->http->request())->asString());
122 break;
123 }
124 }
foreach($components as $component) $resolver

References $resolver, ILIAS\AuthApache\AuthProviderApache\APACHE_AUTH_TYPE_BY_FUNCTION, ILIAS\AuthApache\AuthProviderApache\APACHE_AUTH_TYPE_DIRECT_MAPPING, ilLogLevel\DEBUG, ILIAS\AuthApache\AuthFrontendCredentialsApache\getSettings(), ILIAS\FileDelivery\http(), ILIAS\Repository\logger(), and ilAuthFrontendCredentials\setUsername().

+ Here is the call graph for this function:

◆ tryAuthenticationOnLoginPage()

ILIAS\AuthApache\AuthFrontendCredentialsApache::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 52 of file AuthFrontendCredentialsApache.php.

52 : void
53 {
54 if (!$this->getSettings()->get('apache_enable_auth', '0')) {
55 return;
56 }
57
58 if (!$this->getSettings()->get('apache_auth_authenticate_on_login_page', '0')) {
59 return;
60 }
61
62 if ((\defined('IL_CERT_SSO') && \IL_CERT_SSO === true) ||
64 $this->http->wrapper()->query()->has('passed_sso')) {
65 return;
66 }
67
68 $redirect_url = ilUtil::getHtmlPath('./sso/index.php?force_mode_apache=1');
69
70 if ($this->http->wrapper()->query()->has('target')) {
71 $url = (string) ($this->http->request()->getServerParams()['REQUEST_URI'] ?? '');
72 if (str_starts_with($url, '/')) {
73 $url = substr($url, 1);
74 }
75
76 if (!str_starts_with($url, 'http')) {
77 $parts = parse_url(ILIAS_HTTP_PATH);
78 $url = $parts['scheme'] . '://' . $parts['host'] . '/' . $url;
79 }
80
81 $uri = new \ILIAS\Data\URI($url);
82 /*
83 * If `tryAuthenticationOnLoginPage` is called and a permanent-link "target" is provided,
84 * we ensure using `goto.php` as landing page after successful authentication
85 */
86 $uri = $uri->withPath(str_replace(['login.php', 'ilias.php'], 'goto.php', $uri->getPath()));
88 $redirect_url,
89 'r=' . urlencode($this->refinery->uri()->toString()->transform($uri))
90 );
91 }
92
93 $this->ctrl->redirectToURL($redirect_url);
94 }
const IL_CERT_SSO(isset($_GET['client_id']))
Definition: index.php:47
static supportsRedirects()
Are redirects supported?
Definition: ilContext.php:89
static getHtmlPath(string $relative_path)
get url of path
if($clientAssertionType !='urn:ietf:params:oauth:client-assertion-type:jwt-bearer'|| $grantType !='client_credentials') $parts
Definition: ltitoken.php:61
$url
Definition: shib_logout.php:70

References $parts, $url, ilUtil\appendUrlParameterString(), ILIAS\Repository\ctrl(), ilUtil\getHtmlPath(), ILIAS\AuthApache\AuthFrontendCredentialsApache\getSettings(), ILIAS\FileDelivery\http(), IL_CERT_SSO, ILIAS\Repository\refinery(), and ilContext\supportsRedirects().

+ Here is the call graph for this function:

Field Documentation

◆ $settings

readonly ilSetting ILIAS\AuthApache\AuthFrontendCredentialsApache::$settings
private

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