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

Public Member Functions

 __construct (private string $url, array $whitelist)
 
 isValid ()
 

Private Member Functions

 isValidHost (string $host)
 

Private Attributes

array $whitelist
 

Detailed Description

Definition at line 23 of file WhiteListUrlValidator.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\AuthApache\WhiteListUrlValidator::__construct ( private string  $url,
array  $whitelist 
)
Parameters
list<string>$whitelist

Definition at line 31 of file WhiteListUrlValidator.php.

32 {
33 $this->whitelist = array_filter(array_map(static function (string $domain): string {
34 return trim($domain);
35 }, $whitelist));
36 }

References ILIAS\AuthApache\WhiteListUrlValidator\$whitelist.

Member Function Documentation

◆ isValid()

ILIAS\AuthApache\WhiteListUrlValidator::isValid ( )

Definition at line 60 of file WhiteListUrlValidator.php.

60 : bool
61 {
62 $host = parse_url($this->url, PHP_URL_HOST);
63 if ($host === null) {
64 return false;
65 }
66
67 return $this->isValidHost($host);
68 }

References ILIAS\AuthApache\WhiteListUrlValidator\isValidHost().

+ Here is the call graph for this function:

◆ isValidHost()

ILIAS\AuthApache\WhiteListUrlValidator::isValidHost ( string  $host)
private

Definition at line 38 of file WhiteListUrlValidator.php.

38 : bool
39 {
40 foreach ($this->whitelist as $valid_host) {
41 if ($host === $valid_host) {
42 return true;
43 }
44
45 if (!str_starts_with($valid_host, '.')) {
46 $valid_host = '.' . $valid_host;
47 }
48
49 if ((\strlen($host) > \strlen($valid_host)) && substr(
50 $host,
51 (0 - \strlen($valid_host))
52 ) === $valid_host) {
53 return true;
54 }
55 }
56
57 return false;
58 }

Referenced by ILIAS\AuthApache\WhiteListUrlValidator\isValid().

+ Here is the caller graph for this function:

Field Documentation

◆ $whitelist

array ILIAS\AuthApache\WhiteListUrlValidator::$whitelist
private

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