| @@ 169-175 (lines=7) @@ | ||
| 166 | ||
| 167 | $service->get( |
|
| 168 | '/client_certificate_list', |
|
| 169 | function (Request $request, array $hookData) { |
|
| 170 | AuthUtils::requireUser($hookData, ['vpn-user-portal', 'vpn-admin-portal']); |
|
| 171 | ||
| 172 | $userId = InputValidation::userId($request->getQueryParameter('user_id')); |
|
| 173 | ||
| 174 | return new ApiResponse('client_certificate_list', $this->storage->getCertificates($userId)); |
|
| 175 | } |
|
| 176 | ); |
|
| 177 | ||
| 178 | $service->get( |
|
| @@ 180-186 (lines=7) @@ | ||
| 177 | ||
| 178 | $service->get( |
|
| 179 | '/client_certificate_info', |
|
| 180 | function (Request $request, array $hookData) { |
|
| 181 | AuthUtils::requireUser($hookData, ['vpn-user-portal', 'vpn-admin-portal']); |
|
| 182 | ||
| 183 | $commonName = InputValidation::commonName($request->getQueryParameter('common_name')); |
|
| 184 | ||
| 185 | return new ApiResponse('client_certificate_info', $this->storage->getUserCertificateInfo($commonName)); |
|
| 186 | } |
|
| 187 | ); |
|
| 188 | } |
|
| 189 | } |
|
| @@ 34-40 (lines=7) @@ | ||
| 31 | { |
|
| 32 | $service->get( |
|
| 33 | '/system_messages', |
|
| 34 | function (Request $request, array $hookData) { |
|
| 35 | AuthUtils::requireUser($hookData, ['vpn-admin-portal', 'vpn-user-portal']); |
|
| 36 | ||
| 37 | $type = InputValidation::messageType($request->getQueryParameter('message_type')); |
|
| 38 | ||
| 39 | return new ApiResponse('system_messages', $this->storage->systemMessages($type)); |
|
| 40 | } |
|
| 41 | ); |
|
| 42 | ||
| 43 | $service->post( |
|
| @@ 62-68 (lines=7) @@ | ||
| 59 | ||
| 60 | $service->post( |
|
| 61 | '/delete_system_message', |
|
| 62 | function (Request $request, array $hookData) { |
|
| 63 | AuthUtils::requireUser($hookData, ['vpn-admin-portal']); |
|
| 64 | ||
| 65 | $messageId = InputValidation::messageId($request->getPostParameter('message_id')); |
|
| 66 | ||
| 67 | return new ApiResponse('delete_system_message', $this->storage->deleteSystemMessage($messageId)); |
|
| 68 | } |
|
| 69 | ); |
|
| 70 | } |
|
| 71 | } |
|
| @@ 30-42 (lines=13) @@ | ||
| 27 | $this->storage = $storage; |
|
| 28 | } |
|
| 29 | ||
| 30 | public function init(Service $service) |
|
| 31 | { |
|
| 32 | $service->get( |
|
| 33 | '/user_messages', |
|
| 34 | function (Request $request, array $hookData) { |
|
| 35 | AuthUtils::requireUser($hookData, ['vpn-admin-portal', 'vpn-user-portal']); |
|
| 36 | ||
| 37 | $userId = InputValidation::userId($request->getQueryParameter('user_id')); |
|
| 38 | ||
| 39 | return new ApiResponse('user_messages', $this->storage->userMessages($userId)); |
|
| 40 | } |
|
| 41 | ); |
|
| 42 | } |
|
| 43 | } |
|
| 44 | ||
| @@ 112-118 (lines=7) @@ | ||
| 109 | ||
| 110 | $service->get( |
|
| 111 | '/has_yubi_key_id', |
|
| 112 | function (Request $request, array $hookData) { |
|
| 113 | AuthUtils::requireUser($hookData, ['vpn-user-portal', 'vpn-admin-portal']); |
|
| 114 | ||
| 115 | $userId = InputValidation::userId($request->getQueryParameter('user_id')); |
|
| 116 | ||
| 117 | return new ApiResponse('has_yubi_key_id', $this->storage->hasYubiKeyId($userId)); |
|
| 118 | } |
|
| 119 | ); |
|
| 120 | ||
| 121 | $service->get( |
|
| @@ 207-213 (lines=7) @@ | ||
| 204 | ||
| 205 | $service->get( |
|
| 206 | '/has_totp_secret', |
|
| 207 | function (Request $request, array $hookData) { |
|
| 208 | AuthUtils::requireUser($hookData, ['vpn-user-portal', 'vpn-admin-portal']); |
|
| 209 | ||
| 210 | $userId = InputValidation::userId($request->getQueryParameter('user_id')); |
|
| 211 | ||
| 212 | return new ApiResponse('has_totp_secret', $this->storage->hasTotpSecret($userId)); |
|
| 213 | } |
|
| 214 | ); |
|
| 215 | ||
| 216 | $service->post( |
|
| @@ 218-226 (lines=9) @@ | ||
| 215 | ||
| 216 | $service->post( |
|
| 217 | '/delete_totp_secret', |
|
| 218 | function (Request $request, array $hookData) { |
|
| 219 | AuthUtils::requireUser($hookData, ['vpn-admin-portal']); |
|
| 220 | ||
| 221 | $userId = InputValidation::userId($request->getPostParameter('user_id')); |
|
| 222 | ||
| 223 | $this->storage->deleteTotpSecret($userId); |
|
| 224 | $this->storage->addUserMessage($userId, 'notification', 'TOTP secret deleted'); |
|
| 225 | ||
| 226 | return new ApiResponse('delete_totp_secret'); |
|
| 227 | } |
|
| 228 | ); |
|
| 229 | ||
| @@ 247-253 (lines=7) @@ | ||
| 244 | ||
| 245 | $service->post( |
|
| 246 | '/delete_voot_token', |
|
| 247 | function (Request $request, array $hookData) { |
|
| 248 | AuthUtils::requireUser($hookData, ['vpn-admin-portal']); |
|
| 249 | ||
| 250 | $userId = InputValidation::userId($request->getPostParameter('user_id')); |
|
| 251 | $this->storage->deleteVootToken($userId); |
|
| 252 | ||
| 253 | return new ApiResponse('delete_voot_token'); |
|
| 254 | } |
|
| 255 | ); |
|
| 256 | ||
| @@ 259-265 (lines=7) @@ | ||
| 256 | ||
| 257 | $service->get( |
|
| 258 | '/has_voot_token', |
|
| 259 | function (Request $request, array $hookData) { |
|
| 260 | AuthUtils::requireUser($hookData, ['vpn-user-portal', 'vpn-admin-portal']); |
|
| 261 | ||
| 262 | $userId = InputValidation::userId($request->getQueryParameter('user_id')); |
|
| 263 | ||
| 264 | return new ApiResponse('has_voot_token', $this->storage->hasVootToken($userId)); |
|
| 265 | } |
|
| 266 | ); |
|
| 267 | ||
| 268 | $service->get( |
|
| @@ 270-276 (lines=7) @@ | ||
| 267 | ||
| 268 | $service->get( |
|
| 269 | '/is_disabled_user', |
|
| 270 | function (Request $request, array $hookData) { |
|
| 271 | AuthUtils::requireUser($hookData, ['vpn-admin-portal', 'vpn-user-portal']); |
|
| 272 | ||
| 273 | $userId = InputValidation::userId($request->getQueryParameter('user_id')); |
|
| 274 | ||
| 275 | return new ApiResponse('is_disabled_user', $this->storage->isDisabledUser($userId)); |
|
| 276 | } |
|
| 277 | ); |
|
| 278 | ||
| 279 | $service->post( |
|
| @@ 281-289 (lines=9) @@ | ||
| 278 | ||
| 279 | $service->post( |
|
| 280 | '/disable_user', |
|
| 281 | function (Request $request, array $hookData) { |
|
| 282 | AuthUtils::requireUser($hookData, ['vpn-admin-portal']); |
|
| 283 | ||
| 284 | $userId = InputValidation::userId($request->getPostParameter('user_id')); |
|
| 285 | ||
| 286 | $this->storage->disableUser($userId); |
|
| 287 | $this->storage->addUserMessage($userId, 'notification', 'account disabled'); |
|
| 288 | ||
| 289 | return new ApiResponse('disable_user'); |
|
| 290 | } |
|
| 291 | ); |
|
| 292 | ||
| @@ 295-303 (lines=9) @@ | ||
| 292 | ||
| 293 | $service->post( |
|
| 294 | '/enable_user', |
|
| 295 | function (Request $request, array $hookData) { |
|
| 296 | AuthUtils::requireUser($hookData, ['vpn-admin-portal']); |
|
| 297 | ||
| 298 | $userId = InputValidation::userId($request->getPostParameter('user_id')); |
|
| 299 | ||
| 300 | $this->storage->enableUser($userId); |
|
| 301 | $this->storage->addUserMessage($userId, 'notification', 'account (re)enabled'); |
|
| 302 | ||
| 303 | return new ApiResponse('enable_user'); |
|
| 304 | } |
|
| 305 | ); |
|
| 306 | ||
| @@ 309-315 (lines=7) @@ | ||
| 306 | ||
| 307 | $service->post( |
|
| 308 | '/delete_user', |
|
| 309 | function (Request $request, array $hookData) { |
|
| 310 | AuthUtils::requireUser($hookData, ['vpn-admin-portal']); |
|
| 311 | ||
| 312 | $userId = InputValidation::userId($request->getPostParameter('user_id')); |
|
| 313 | $this->storage->deleteUser($userId); |
|
| 314 | ||
| 315 | return new ApiResponse('delete_user'); |
|
| 316 | } |
|
| 317 | ); |
|
| 318 | ||
| @@ 61-67 (lines=7) @@ | ||
| 58 | ||
| 59 | $service->post( |
|
| 60 | '/kill_client', |
|
| 61 | function (Request $request, array $hookData) { |
|
| 62 | AuthUtils::requireUser($hookData, ['vpn-admin-portal', 'vpn-user-portal']); |
|
| 63 | ||
| 64 | $commonName = InputValidation::commonName($request->getPostParameter('common_name')); |
|
| 65 | ||
| 66 | return new ApiResponse('kill_client', $this->serverManager->kill($commonName)); |
|
| 67 | } |
|
| 68 | ); |
|
| 69 | } |
|
| 70 | } |
|