1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace SimpleSAML\Module\memcacheMonitor\Controller; |
6
|
|
|
|
7
|
|
|
use SimpleSAML\Configuration; |
8
|
|
|
use SimpleSAML\Module\memcacheMonitor\MemcacheMonitor; |
9
|
|
|
use SimpleSAML\Session; |
10
|
|
|
use SimpleSAML\Utils; |
11
|
|
|
use SimpleSAML\XHTML\Template; |
12
|
|
|
use Symfony\Component\HttpFoundation\Request; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Controller class for the memcacheMonitor module. |
16
|
|
|
* |
17
|
|
|
* This class serves the different views available in the module. |
18
|
|
|
* |
19
|
|
|
* @package SimpleSAML\Module\memcacheMonitor |
20
|
|
|
*/ |
21
|
|
|
class MemcacheMonitorController |
22
|
|
|
{ |
23
|
|
|
/** @var \SimpleSAML\Configuration */ |
24
|
|
|
protected Configuration $config; |
25
|
|
|
|
26
|
|
|
/** @var \SimpleSAML\Session */ |
27
|
|
|
protected Session $session; |
28
|
|
|
|
29
|
|
|
/** @var \SimpleSAML\Utils\Auth */ |
30
|
|
|
protected $authUtils; |
31
|
|
|
|
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Controller constructor. |
35
|
|
|
* |
36
|
|
|
* It initializes the global configuration and auth source configuration for the controllers implemented here. |
37
|
|
|
* |
38
|
|
|
* @param \SimpleSAML\Configuration $config The configuration to use by the controllers. |
39
|
|
|
* @param \SimpleSAML\Session $session The session to use by the controllers. |
40
|
|
|
* |
41
|
|
|
* @throws \Exception |
42
|
|
|
*/ |
43
|
|
|
public function __construct( |
44
|
|
|
Configuration $config, |
45
|
|
|
Session $session, |
46
|
|
|
) { |
47
|
|
|
$this->config = $config; |
48
|
|
|
$this->session = $session; |
49
|
|
|
$this->authUtils = new Utils\Auth(); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Inject the \SimpleSAML\Utils\Auth dependency. |
55
|
|
|
* |
56
|
|
|
* @param \SimpleSAML\Utils\Auth $authUtils |
57
|
|
|
*/ |
58
|
|
|
public function setAuthUtils(Utils\Auth $authUtils): void |
59
|
|
|
{ |
60
|
|
|
$this->authUtils = $authUtils; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* Show memcache info. |
66
|
|
|
* |
67
|
|
|
* @param \Symfony\Component\HttpFoundation\Request $request |
68
|
|
|
* @return \SimpleSAML\XHTML\Template |
69
|
|
|
* An HTML template or a redirection if we are not authenticated. |
70
|
|
|
*/ |
71
|
|
|
public function main(Request $request): Template |
|
|
|
|
72
|
|
|
{ |
73
|
|
|
$this->authUtils->requireAdmin(); |
74
|
|
|
|
75
|
|
|
$memcacheMonitor = new MemcacheMonitor($this->config); |
76
|
|
|
return $memcacheMonitor->renderStats(); |
77
|
|
|
} |
78
|
|
|
} |
79
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.