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