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

Public Member Functions

 __construct (ServerRequestInterface $http_request, 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

ServerRequestInterface $http_request
 
ilCtrlInterface $ctrl
 
ilSetting $settings
 

Additional Inherited Members

- Protected Attributes inherited from ilAuthFrontendCredentials
ilLogger $logger
 

Detailed Description

Definition at line 34 of file AuthFrontendCredentialsApache.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\AuthApache\AuthFrontendCredentialsApache::__construct ( ServerRequestInterface  $http_request,
ilCtrlInterface  $ctrl 
)

Member Function Documentation

◆ getSettings()

ILIAS\AuthApache\AuthFrontendCredentialsApache::getSettings ( )
protected

◆ getTargetUrl()

ILIAS\AuthApache\AuthFrontendCredentialsApache::getTargetUrl ( )

Definition at line 149 of file AuthFrontendCredentialsApache.php.

149 : string
150 {
151 return ilUtil::appendUrlParameterString(trim($this->http_request->getQueryParams()['r']), 'passed_sso=1');
152 }
static appendUrlParameterString(string $a_url, string $a_par, bool $xml_style=false)

References ilUtil\appendUrlParameterString().

+ Here is the call graph for this function:

◆ hasValidTargetUrl()

ILIAS\AuthApache\AuthFrontendCredentialsApache::hasValidTargetUrl ( )

Definition at line 129 of file AuthFrontendCredentialsApache.php.

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

References $path, CLIENT_ID, and ILIAS_DATA_DIR.

◆ initFromRequest()

ILIAS\AuthApache\AuthFrontendCredentialsApache::initFromRequest ( )

Definition at line 104 of file AuthFrontendCredentialsApache.php.

104 : void
105 {
106 $mapping_field_name = $this->getSettings()->get('apache_auth_username_direct_mapping_fieldname', '');
107
108 $this->logger->dump($this->http_request->getServerParams(), ilLogLevel::DEBUG);
109 $this->logger->debug($mapping_field_name);
110
111 switch ($this->getSettings()->get('apache_auth_username_config_type')) {
113 if (isset($this->http_request->getServerParams()[$mapping_field_name])) {
114 $this->setUsername($this->http_request->getServerParams()[$mapping_field_name]);
115 }
116 break;
117
119 $factory = new UsernameProviderFactory();
120 $resolver = new UsernameResolver($factory->fromClassNames(
121 require CollectUsernameProvidersObjective::PATH()
122 ), $this->logger);
123
124 $this->setUsername($resolver->resolve($this->http_request)->asString());
125 break;
126 }
127 }
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\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 $cmd = (string) ($this->http_request->getQueryParams()['cmd'] ?? '');
55 if ($cmd === '') {
56 $cmd = (string) ($this->http_request->getParsedBody()['cmd'] ?? '');
57 }
58
59 if ($cmd === 'force_login') {
60 return;
61 }
62
63 if (!$this->getSettings()->get('apache_enable_auth', '0')) {
64 return;
65 }
66
67 if (!$this->getSettings()->get('apache_auth_authenticate_on_login_page', '0')) {
68 return;
69 }
70
71 if ((\defined('IL_CERT_SSO') && \IL_CERT_SSO === true) ||
73 isset($this->http_request->getQueryParams()['passed_sso'])) {
74 return;
75 }
76
77 $path = (string) ($this->http_request->getServerParams()['REQUEST_URI'] ?? '');
78 if (str_starts_with($path, '/')) {
79 $path = substr($path, 1);
80 }
81
82 if (!str_starts_with($path, 'http')) {
83 $parts = parse_url(ILIAS_HTTP_PATH);
84 $path = $parts['scheme'] . '://' . $parts['host'] . '/' . $path;
85 }
86
87 $this->ctrl->redirectToURL(
89 './sso/index.php?' . http_build_query([
90 'force_mode_apache' => 1,
91 'r' => $path,
92 'cookie_path' => IL_COOKIE_PATH,
93 'ilias_path' => ILIAS_HTTP_PATH,
94 ])
95 )
96 );
97 }
const IL_CERT_SSO(isset($_GET['client_id']))
Definition: index.php:47
const IL_COOKIE_PATH
Definition: index.php:48
static supportsRedirects()
Are redirects supported?
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

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

+ Here is the call graph for this function:

Field Documentation

◆ $ctrl

ilCtrlInterface ILIAS\AuthApache\AuthFrontendCredentialsApache::$ctrl
private

◆ $http_request

ServerRequestInterface ILIAS\AuthApache\AuthFrontendCredentialsApache::$http_request
private

◆ $settings

ilSetting ILIAS\AuthApache\AuthFrontendCredentialsApache::$settings
private

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