|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* sysPass |
|
4
|
|
|
* |
|
5
|
|
|
* @author nuxsmin |
|
6
|
|
|
* @link https://syspass.org |
|
7
|
|
|
* @copyright 2012-2018, Rubén Domínguez nuxsmin@$syspass.org |
|
8
|
|
|
* |
|
9
|
|
|
* This file is part of sysPass. |
|
10
|
|
|
* |
|
11
|
|
|
* sysPass is free software: you can redistribute it and/or modify |
|
12
|
|
|
* it under the terms of the GNU General Public License as published by |
|
13
|
|
|
* the Free Software Foundation, either version 3 of the License, or |
|
14
|
|
|
* (at your option) any later version. |
|
15
|
|
|
* |
|
16
|
|
|
* sysPass is distributed in the hope that it will be useful, |
|
17
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
18
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
19
|
|
|
* GNU General Public License for more details. |
|
20
|
|
|
* |
|
21
|
|
|
* You should have received a copy of the GNU General Public License |
|
22
|
|
|
* along with sysPass. If not, see <http://www.gnu.org/licenses/>. |
|
23
|
|
|
*/ |
|
24
|
|
|
|
|
25
|
|
|
namespace SP\Modules\Web\Controllers\Traits; |
|
26
|
|
|
|
|
27
|
|
|
use Klein\Klein; |
|
28
|
|
|
use Psr\Container\ContainerInterface; |
|
29
|
|
|
use SP\Config\Config; |
|
30
|
|
|
use SP\Config\ConfigData; |
|
31
|
|
|
use SP\Core\Acl\Acl; |
|
32
|
|
|
use SP\Core\Context\ContextInterface; |
|
33
|
|
|
use SP\Core\Context\SessionContext; |
|
34
|
|
|
use SP\Core\Events\EventDispatcher; |
|
35
|
|
|
use SP\Core\Exceptions\SPException; |
|
36
|
|
|
use SP\Core\PhpExtensionChecker; |
|
37
|
|
|
use SP\Core\UI\Theme; |
|
38
|
|
|
use SP\Http\Request; |
|
39
|
|
|
use SP\Mvc\Controller\ControllerTrait; |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* Trait ControllerTratit |
|
43
|
|
|
* |
|
44
|
|
|
* @package SP\Modules\Web\Controllers |
|
45
|
|
|
*/ |
|
46
|
|
|
trait WebControllerTrait |
|
47
|
|
|
{ |
|
48
|
|
|
use ControllerTrait; |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* @var string Nombre del controlador |
|
52
|
|
|
*/ |
|
53
|
|
|
protected $controllerName; |
|
54
|
|
|
/** |
|
55
|
|
|
* @var EventDispatcher |
|
56
|
|
|
*/ |
|
57
|
|
|
protected $eventDispatcher; |
|
58
|
|
|
/** |
|
59
|
|
|
* @var Config |
|
60
|
|
|
*/ |
|
61
|
|
|
protected $config; |
|
62
|
|
|
/** |
|
63
|
|
|
* @var SessionContext |
|
64
|
|
|
*/ |
|
65
|
|
|
protected $session; |
|
66
|
|
|
/** |
|
67
|
|
|
* @var Theme |
|
68
|
|
|
*/ |
|
69
|
|
|
protected $theme; |
|
70
|
|
|
/** |
|
71
|
|
|
* @var string |
|
72
|
|
|
*/ |
|
73
|
|
|
protected $actionName; |
|
74
|
|
|
/** |
|
75
|
|
|
* @var Klein |
|
76
|
|
|
*/ |
|
77
|
|
|
protected $router; |
|
78
|
|
|
/** |
|
79
|
|
|
* @var Acl |
|
80
|
|
|
*/ |
|
81
|
|
|
protected $acl; |
|
82
|
|
|
/** |
|
83
|
|
|
* @var ConfigData |
|
84
|
|
|
*/ |
|
85
|
|
|
protected $configData; |
|
86
|
|
|
/** |
|
87
|
|
|
* @var Request |
|
88
|
|
|
*/ |
|
89
|
|
|
protected $request; |
|
90
|
|
|
/** |
|
91
|
|
|
* @var PhpExtensionChecker |
|
92
|
|
|
*/ |
|
93
|
|
|
protected $extensionChecker; |
|
94
|
|
|
/** |
|
95
|
|
|
* @var bool |
|
96
|
|
|
*/ |
|
97
|
|
|
private $setup = false; |
|
98
|
|
|
|
|
99
|
|
|
/** |
|
100
|
|
|
* Returns the signed URI component after validating its signature. |
|
101
|
|
|
* This component is used for deep linking |
|
102
|
|
|
* |
|
103
|
|
|
* @return null|string |
|
104
|
|
|
*/ |
|
105
|
|
|
final protected function getSignedUriFromRequest() |
|
106
|
|
|
{ |
|
107
|
|
|
if (!$this->setup) { |
|
108
|
|
|
return null; |
|
109
|
|
|
} |
|
110
|
|
|
|
|
111
|
|
|
$from = $this->request->analyzeString('from'); |
|
112
|
|
|
|
|
113
|
|
|
if ($from) { |
|
114
|
|
|
try { |
|
115
|
|
|
$this->request->verifySignature($this->configData->getPasswordSalt(), 'from'); |
|
116
|
|
|
} catch (SPException $e) { |
|
117
|
|
|
processException($e); |
|
118
|
|
|
|
|
119
|
|
|
$from = null; |
|
120
|
|
|
} |
|
121
|
|
|
} |
|
122
|
|
|
|
|
123
|
|
|
return $from; |
|
124
|
|
|
} |
|
125
|
|
|
|
|
126
|
|
|
/** |
|
127
|
|
|
* @param ContainerInterface $dic |
|
128
|
|
|
*/ |
|
129
|
|
|
private function setUp(ContainerInterface $dic) |
|
130
|
|
|
{ |
|
131
|
|
|
$this->controllerName = $this->getControllerName(); |
|
132
|
|
|
|
|
133
|
|
|
$this->config = $dic->get(Config::class); |
|
134
|
|
|
$this->configData = $this->config->getConfigData(); |
|
135
|
|
|
$this->session = $dic->get(ContextInterface::class); |
|
136
|
|
|
$this->theme = $dic->get(Theme::class); |
|
137
|
|
|
$this->eventDispatcher = $dic->get(EventDispatcher::class); |
|
138
|
|
|
$this->router = $dic->get(Klein::class); |
|
139
|
|
|
$this->request = $dic->get(Request::class); |
|
140
|
|
|
$this->acl = $dic->get(Acl::class); |
|
141
|
|
|
$this->extensionChecker = $dic->get(PhpExtensionChecker::class); |
|
142
|
|
|
|
|
143
|
|
|
$this->setup = true; |
|
144
|
|
|
} |
|
145
|
|
|
} |