|
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; |
|
26
|
|
|
|
|
27
|
|
|
use SP\Core\Acl\Acl; |
|
28
|
|
|
use SP\Core\Events\Event; |
|
29
|
|
|
use SP\DataModel\ItemSearchData; |
|
30
|
|
|
use SP\Modules\Web\Controllers\Helpers\Grid\AuthTokenGrid; |
|
31
|
|
|
use SP\Modules\Web\Controllers\Helpers\Grid\PublicLinkGrid; |
|
32
|
|
|
use SP\Modules\Web\Controllers\Helpers\Grid\UserGrid; |
|
33
|
|
|
use SP\Modules\Web\Controllers\Helpers\Grid\UserGroupGrid; |
|
34
|
|
|
use SP\Modules\Web\Controllers\Helpers\Grid\UserProfileGrid; |
|
35
|
|
|
use SP\Modules\Web\Controllers\Helpers\TabsGridHelper; |
|
36
|
|
|
use SP\Services\AuthToken\AuthTokenService; |
|
37
|
|
|
use SP\Services\PublicLink\PublicLinkService; |
|
38
|
|
|
use SP\Services\User\UserService; |
|
39
|
|
|
use SP\Services\UserGroup\UserGroupService; |
|
40
|
|
|
use SP\Services\UserProfile\UserProfileService; |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* Class AccessManagerController |
|
44
|
|
|
* |
|
45
|
|
|
* @package SP\Modules\Web\Controllers |
|
46
|
|
|
*/ |
|
47
|
|
|
final class AccessManagerController extends ControllerBase |
|
48
|
|
|
{ |
|
49
|
|
|
/** |
|
50
|
|
|
* @var ItemSearchData |
|
51
|
|
|
*/ |
|
52
|
|
|
protected $itemSearchData; |
|
53
|
|
|
/** |
|
54
|
|
|
* @var TabsGridHelper |
|
55
|
|
|
*/ |
|
56
|
|
|
protected $tabsGridHelper; |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* @throws \DI\DependencyException |
|
60
|
|
|
* @throws \DI\NotFoundException |
|
61
|
|
|
* @throws \SP\Core\Exceptions\ConstraintException |
|
62
|
|
|
* @throws \SP\Core\Exceptions\QueryException |
|
63
|
|
|
*/ |
|
64
|
|
|
public function indexAction() |
|
65
|
|
|
{ |
|
66
|
|
|
$this->getGridTabs(); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* Returns a tabbed grid with items |
|
71
|
|
|
* |
|
72
|
|
|
* @throws \DI\DependencyException |
|
73
|
|
|
* @throws \DI\NotFoundException |
|
74
|
|
|
* @throws \SP\Core\Exceptions\ConstraintException |
|
75
|
|
|
* @throws \SP\Core\Exceptions\QueryException |
|
76
|
|
|
*/ |
|
77
|
|
|
protected function getGridTabs() |
|
78
|
|
|
{ |
|
79
|
|
|
$this->itemSearchData = new ItemSearchData(); |
|
80
|
|
|
$this->itemSearchData->setLimitCount($this->configData->getAccountCount()); |
|
81
|
|
|
|
|
82
|
|
|
$this->tabsGridHelper = $this->dic->get(TabsGridHelper::class); |
|
83
|
|
|
|
|
84
|
|
|
if ($this->checkAccess(Acl::USER)) { |
|
85
|
|
|
$this->tabsGridHelper->addTab($this->getUsersList()); |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
if ($this->checkAccess(Acl::GROUP)) { |
|
89
|
|
|
$this->tabsGridHelper->addTab($this->getUsersGroupList()); |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
if ($this->checkAccess(Acl::PROFILE)) { |
|
93
|
|
|
$this->tabsGridHelper->addTab($this->getUsersProfileList()); |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
if ($this->checkAccess(Acl::AUTHTOKEN)) { |
|
97
|
|
|
$this->tabsGridHelper->addTab($this->getAuthTokensList()); |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
if ($this->configData->isPublinksEnabled() && $this->checkAccess(Acl::PUBLICLINK)) { |
|
101
|
|
|
$this->tabsGridHelper->addTab($this->getPublicLinksList()); |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
$this->eventDispatcher->notifyEvent('show.itemlist.accesses', new Event($this)); |
|
105
|
|
|
|
|
106
|
|
|
$this->tabsGridHelper->renderTabs(Acl::getActionRoute(Acl::ACCESS_MANAGE), $this->request->analyzeInt('tabIndex', 0)); |
|
107
|
|
|
|
|
108
|
|
|
$this->view(); |
|
109
|
|
|
} |
|
110
|
|
|
|
|
111
|
|
|
/** |
|
112
|
|
|
* Returns users' data tab |
|
113
|
|
|
* |
|
114
|
|
|
* @return \SP\Html\DataGrid\DataGridTab |
|
115
|
|
|
* @throws \DI\DependencyException |
|
116
|
|
|
* @throws \DI\NotFoundException |
|
117
|
|
|
* @throws \SP\Core\Exceptions\ConstraintException |
|
118
|
|
|
* @throws \SP\Core\Exceptions\QueryException |
|
119
|
|
|
*/ |
|
120
|
|
|
protected function getUsersList() |
|
121
|
|
|
{ |
|
122
|
|
|
return $this->dic->get(UserGrid::class) |
|
123
|
|
|
->getGrid($this->dic->get(UserService::class)->search($this->itemSearchData)) |
|
124
|
|
|
->updatePager(); |
|
125
|
|
|
} |
|
126
|
|
|
|
|
127
|
|
|
/** |
|
128
|
|
|
* Returns users group data tab |
|
129
|
|
|
* |
|
130
|
|
|
* @return \SP\Html\DataGrid\DataGridTab |
|
131
|
|
|
* @throws \DI\DependencyException |
|
132
|
|
|
* @throws \DI\NotFoundException |
|
133
|
|
|
* @throws \SP\Core\Exceptions\ConstraintException |
|
134
|
|
|
* @throws \SP\Core\Exceptions\QueryException |
|
135
|
|
|
*/ |
|
136
|
|
|
protected function getUsersGroupList() |
|
137
|
|
|
{ |
|
138
|
|
|
return $this->dic->get(UserGroupGrid::class) |
|
139
|
|
|
->getGrid($this->dic->get(UserGroupService::class)->search($this->itemSearchData)) |
|
140
|
|
|
->updatePager(); |
|
141
|
|
|
} |
|
142
|
|
|
|
|
143
|
|
|
/** |
|
144
|
|
|
* Returns users profile data tab |
|
145
|
|
|
* |
|
146
|
|
|
* @return \SP\Html\DataGrid\DataGridTab |
|
147
|
|
|
* @throws \DI\DependencyException |
|
148
|
|
|
* @throws \DI\NotFoundException |
|
149
|
|
|
* @throws \SP\Core\Exceptions\ConstraintException |
|
150
|
|
|
* @throws \SP\Core\Exceptions\QueryException |
|
151
|
|
|
*/ |
|
152
|
|
|
protected function getUsersProfileList() |
|
153
|
|
|
{ |
|
154
|
|
|
return $this->dic->get(UserProfileGrid::class) |
|
155
|
|
|
->getGrid($this->dic->get(UserProfileService::class)->search($this->itemSearchData)) |
|
156
|
|
|
->updatePager(); |
|
157
|
|
|
} |
|
158
|
|
|
|
|
159
|
|
|
/** |
|
160
|
|
|
* Returns API tokens data tab |
|
161
|
|
|
* |
|
162
|
|
|
* @return \SP\Html\DataGrid\DataGridTab |
|
163
|
|
|
* @throws \DI\DependencyException |
|
164
|
|
|
* @throws \DI\NotFoundException |
|
165
|
|
|
* @throws \SP\Core\Exceptions\ConstraintException |
|
166
|
|
|
* @throws \SP\Core\Exceptions\QueryException |
|
167
|
|
|
*/ |
|
168
|
|
|
protected function getAuthTokensList() |
|
169
|
|
|
{ |
|
170
|
|
|
return $this->dic->get(AuthTokenGrid::class) |
|
171
|
|
|
->getGrid($this->dic->get(AuthTokenService::class)->search($this->itemSearchData)) |
|
172
|
|
|
->updatePager(); |
|
173
|
|
|
} |
|
174
|
|
|
|
|
175
|
|
|
/** |
|
176
|
|
|
* Returns public links data tab |
|
177
|
|
|
* |
|
178
|
|
|
* @return \SP\Html\DataGrid\DataGridTab |
|
179
|
|
|
* @throws \DI\DependencyException |
|
180
|
|
|
* @throws \DI\NotFoundException |
|
181
|
|
|
* @throws \SP\Core\Exceptions\ConstraintException |
|
182
|
|
|
* @throws \SP\Core\Exceptions\QueryException |
|
183
|
|
|
*/ |
|
184
|
|
|
protected function getPublicLinksList() |
|
185
|
|
|
{ |
|
186
|
|
|
return $this->dic->get(PublicLinkGrid::class) |
|
187
|
|
|
->getGrid($this->dic->get(PublicLinkService::class)->search($this->itemSearchData)) |
|
188
|
|
|
->updatePager(); |
|
189
|
|
|
} |
|
190
|
|
|
|
|
191
|
|
|
/** |
|
192
|
|
|
* @return TabsGridHelper |
|
193
|
|
|
*/ |
|
194
|
|
|
public function getTabsGridHelper() |
|
195
|
|
|
{ |
|
196
|
|
|
return $this->tabsGridHelper; |
|
197
|
|
|
} |
|
198
|
|
|
|
|
199
|
|
|
/** |
|
200
|
|
|
* @throws \Psr\Container\ContainerExceptionInterface |
|
201
|
|
|
* @throws \Psr\Container\NotFoundExceptionInterface |
|
202
|
|
|
* @throws \SP\Services\Auth\AuthException |
|
203
|
|
|
*/ |
|
204
|
|
|
protected function initialize() |
|
205
|
|
|
{ |
|
206
|
|
|
$this->checkLoggedIn(); |
|
207
|
|
|
} |
|
208
|
|
|
} |