1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace SimpleSAML\Module\casserver\Controller\Traits; |
6
|
|
|
|
7
|
|
|
use SimpleSAML\Module\casserver\Cas\ServiceValidator; |
8
|
|
|
use SimpleSAML\Module\casserver\Cas\TicketValidator; |
9
|
|
|
use Symfony\Component\HttpFoundation\Request; |
10
|
|
|
|
11
|
|
|
trait UrlTrait |
12
|
|
|
{ |
13
|
|
|
/** |
14
|
|
|
* @deprecated |
15
|
|
|
* @see ServiceValidator |
16
|
|
|
* @param string $service |
17
|
|
|
* @param array $legal_service_urls |
18
|
|
|
* @return bool |
19
|
|
|
*/ |
20
|
|
|
public function checkServiceURL(string $service, array $legal_service_urls): bool |
21
|
|
|
{ |
22
|
|
|
//delegate to ServiceValidator until all references to this can be cleaned up |
23
|
|
|
$config = Configuration::loadFromArray(['legal_service_urls' => $legal_service_urls]); |
|
|
|
|
24
|
|
|
$serviceValidator = new ServiceValidator($config); |
25
|
|
|
return $serviceValidator->checkServiceURL($service) !== null; |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @param string $parameter |
31
|
|
|
* @return string |
32
|
|
|
*/ |
33
|
|
|
public function sanitize(string $parameter): string |
34
|
|
|
{ |
35
|
|
|
return TicketValidator::sanitize($parameter); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Parse the query Parameters from $_GET global and return them in an array. |
41
|
|
|
* |
42
|
|
|
* @param array|null $sessionTicket |
43
|
|
|
* @param Request $request |
44
|
|
|
* |
45
|
|
|
* @return array |
46
|
|
|
*/ |
47
|
|
|
public function parseQueryParameters(?array $sessionTicket, Request $request): array |
|
|
|
|
48
|
|
|
{ |
49
|
|
|
$forceAuthn = isset($_GET['renew']) && $_GET['renew']; |
50
|
|
|
$sessionRenewId = $sessionTicket ? $sessionTicket['renewId'] : null; |
51
|
|
|
|
52
|
|
|
$query = []; |
53
|
|
|
|
54
|
|
|
if ($sessionRenewId && $forceAuthn) { |
55
|
|
|
$query['renewId'] = $sessionRenewId; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
if (isset($_REQUEST['service'])) { |
59
|
|
|
$query['service'] = $_REQUEST['service']; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
if (isset($_REQUEST['TARGET'])) { |
63
|
|
|
$query['TARGET'] = $_REQUEST['TARGET']; |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
if (isset($_REQUEST['method'])) { |
67
|
|
|
$query['method'] = $_REQUEST['method']; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
if (isset($_REQUEST['renew'])) { |
71
|
|
|
$query['renew'] = $_REQUEST['renew']; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
if (isset($_REQUEST['gateway'])) { |
75
|
|
|
$query['gateway'] = $_REQUEST['gateway']; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
if (\array_key_exists('language', $_GET)) { |
79
|
|
|
$query['language'] = \is_string($_GET['language']) ? $_GET['language'] : null; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
if (isset($_REQUEST['debugMode'])) { |
83
|
|
|
$query['debugMode'] = $_REQUEST['debugMode']; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
return $query; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* @param Request $request |
91
|
|
|
* |
92
|
|
|
* @return array |
93
|
|
|
*/ |
94
|
|
|
public function getRequestParams(Request $request): array |
95
|
|
|
{ |
96
|
|
|
$params = []; |
97
|
|
|
if ($request->isMethod('GET')) { |
98
|
|
|
$params = $request->query->all(); |
99
|
|
|
} elseif ($request->isMethod('POST')) { |
100
|
|
|
$params = $request->request->all(); |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
return $params; |
104
|
|
|
} |
105
|
|
|
} |
106
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths