| @@ 65-71 (lines=7) @@ | ||
| 62 | ||
| 63 | $service->post( |
|
| 64 | '/kill_client', |
|
| 65 | function (Request $request, array $hookData) { |
|
| 66 | AuthUtils::requireUser($hookData, ['vpn-admin-portal', 'vpn-user-portal']); |
|
| 67 | ||
| 68 | $commonName = InputValidation::commonName($request->getPostParameter('common_name')); |
|
| 69 | ||
| 70 | return new ApiResponse('kill_client', $this->serverManager->kill($commonName)); |
|
| 71 | } |
|
| 72 | ); |
|
| 73 | } |
|
| 74 | } |
|
| @@ 39-51 (lines=13) @@ | ||
| 36 | $this->storage = $storage; |
|
| 37 | } |
|
| 38 | ||
| 39 | public function init(Service $service) |
|
| 40 | { |
|
| 41 | $service->get( |
|
| 42 | '/user_messages', |
|
| 43 | function (Request $request, array $hookData) { |
|
| 44 | AuthUtils::requireUser($hookData, ['vpn-admin-portal', 'vpn-user-portal']); |
|
| 45 | ||
| 46 | $userId = InputValidation::userId($request->getQueryParameter('user_id')); |
|
| 47 | ||
| 48 | return new ApiResponse('user_messages', $this->storage->userMessages($userId)); |
|
| 49 | } |
|
| 50 | ); |
|
| 51 | } |
|
| 52 | } |
|
| 53 | ||
| @@ 163-169 (lines=7) @@ | ||
| 160 | ||
| 161 | $service->get( |
|
| 162 | '/client_certificate_list', |
|
| 163 | function (Request $request, array $hookData) { |
|
| 164 | AuthUtils::requireUser($hookData, ['vpn-user-portal', 'vpn-admin-portal']); |
|
| 165 | ||
| 166 | $userId = InputValidation::userId($request->getQueryParameter('user_id')); |
|
| 167 | ||
| 168 | return new ApiResponse('client_certificate_list', $this->storage->getCertificates($userId)); |
|
| 169 | } |
|
| 170 | ); |
|
| 171 | ||
| 172 | $service->get( |
|
| @@ 174-180 (lines=7) @@ | ||
| 171 | ||
| 172 | $service->get( |
|
| 173 | '/client_certificate_info', |
|
| 174 | function (Request $request, array $hookData) { |
|
| 175 | AuthUtils::requireUser($hookData, ['vpn-user-portal', 'vpn-admin-portal']); |
|
| 176 | ||
| 177 | $commonName = InputValidation::commonName($request->getQueryParameter('common_name')); |
|
| 178 | ||
| 179 | return new ApiResponse('client_certificate_info', $this->storage->getUserCertificateInfo($commonName)); |
|
| 180 | } |
|
| 181 | ); |
|
| 182 | } |
|
| 183 | } |
|
| @@ 43-49 (lines=7) @@ | ||
| 40 | { |
|
| 41 | $service->get( |
|
| 42 | '/system_messages', |
|
| 43 | function (Request $request, array $hookData) { |
|
| 44 | AuthUtils::requireUser($hookData, ['vpn-admin-portal', 'vpn-user-portal']); |
|
| 45 | ||
| 46 | $type = InputValidation::messageType($request->getQueryParameter('message_type')); |
|
| 47 | ||
| 48 | return new ApiResponse('system_messages', $this->storage->systemMessages($type)); |
|
| 49 | } |
|
| 50 | ); |
|
| 51 | ||
| 52 | $service->post( |
|
| @@ 71-77 (lines=7) @@ | ||
| 68 | ||
| 69 | $service->post( |
|
| 70 | '/delete_system_message', |
|
| 71 | function (Request $request, array $hookData) { |
|
| 72 | AuthUtils::requireUser($hookData, ['vpn-admin-portal']); |
|
| 73 | ||
| 74 | $messageId = InputValidation::messageId($request->getPostParameter('message_id')); |
|
| 75 | ||
| 76 | return new ApiResponse('delete_system_message', $this->storage->deleteSystemMessage($messageId)); |
|
| 77 | } |
|
| 78 | ); |
|
| 79 | } |
|
| 80 | } |
|
| @@ 120-126 (lines=7) @@ | ||
| 117 | ||
| 118 | $service->get( |
|
| 119 | '/has_yubi_key_id', |
|
| 120 | function (Request $request, array $hookData) { |
|
| 121 | AuthUtils::requireUser($hookData, ['vpn-user-portal', 'vpn-admin-portal']); |
|
| 122 | ||
| 123 | $userId = InputValidation::userId($request->getQueryParameter('user_id')); |
|
| 124 | ||
| 125 | return new ApiResponse('has_yubi_key_id', $this->storage->hasYubiKeyId($userId)); |
|
| 126 | } |
|
| 127 | ); |
|
| 128 | ||
| 129 | $service->get( |
|
| @@ 215-221 (lines=7) @@ | ||
| 212 | ||
| 213 | $service->get( |
|
| 214 | '/has_totp_secret', |
|
| 215 | function (Request $request, array $hookData) { |
|
| 216 | AuthUtils::requireUser($hookData, ['vpn-user-portal', 'vpn-admin-portal']); |
|
| 217 | ||
| 218 | $userId = InputValidation::userId($request->getQueryParameter('user_id')); |
|
| 219 | ||
| 220 | return new ApiResponse('has_totp_secret', $this->storage->hasTotpSecret($userId)); |
|
| 221 | } |
|
| 222 | ); |
|
| 223 | ||
| 224 | $service->post( |
|
| @@ 226-234 (lines=9) @@ | ||
| 223 | ||
| 224 | $service->post( |
|
| 225 | '/delete_totp_secret', |
|
| 226 | function (Request $request, array $hookData) { |
|
| 227 | AuthUtils::requireUser($hookData, ['vpn-admin-portal']); |
|
| 228 | ||
| 229 | $userId = InputValidation::userId($request->getPostParameter('user_id')); |
|
| 230 | ||
| 231 | $this->storage->deleteTotpSecret($userId); |
|
| 232 | $this->storage->addUserMessage($userId, 'notification', 'TOTP secret deleted'); |
|
| 233 | ||
| 234 | return new ApiResponse('delete_totp_secret'); |
|
| 235 | } |
|
| 236 | ); |
|
| 237 | ||
| @@ 253-259 (lines=7) @@ | ||
| 250 | ||
| 251 | $service->post( |
|
| 252 | '/delete_voot_token', |
|
| 253 | function (Request $request, array $hookData) { |
|
| 254 | AuthUtils::requireUser($hookData, ['vpn-admin-portal']); |
|
| 255 | ||
| 256 | $userId = InputValidation::userId($request->getPostParameter('user_id')); |
|
| 257 | $this->storage->deleteVootToken($userId); |
|
| 258 | ||
| 259 | return new ApiResponse('delete_voot_token'); |
|
| 260 | } |
|
| 261 | ); |
|
| 262 | ||
| @@ 265-271 (lines=7) @@ | ||
| 262 | ||
| 263 | $service->get( |
|
| 264 | '/has_voot_token', |
|
| 265 | function (Request $request, array $hookData) { |
|
| 266 | AuthUtils::requireUser($hookData, ['vpn-user-portal', 'vpn-admin-portal']); |
|
| 267 | ||
| 268 | $userId = InputValidation::userId($request->getQueryParameter('user_id')); |
|
| 269 | ||
| 270 | return new ApiResponse('has_voot_token', $this->storage->hasVootToken($userId)); |
|
| 271 | } |
|
| 272 | ); |
|
| 273 | ||
| 274 | $service->get( |
|
| @@ 276-282 (lines=7) @@ | ||
| 273 | ||
| 274 | $service->get( |
|
| 275 | '/is_disabled_user', |
|
| 276 | function (Request $request, array $hookData) { |
|
| 277 | AuthUtils::requireUser($hookData, ['vpn-admin-portal', 'vpn-user-portal']); |
|
| 278 | ||
| 279 | $userId = InputValidation::userId($request->getQueryParameter('user_id')); |
|
| 280 | ||
| 281 | return new ApiResponse('is_disabled_user', $this->storage->isDisabledUser($userId)); |
|
| 282 | } |
|
| 283 | ); |
|
| 284 | ||
| 285 | $service->post( |
|
| @@ 287-295 (lines=9) @@ | ||
| 284 | ||
| 285 | $service->post( |
|
| 286 | '/disable_user', |
|
| 287 | function (Request $request, array $hookData) { |
|
| 288 | AuthUtils::requireUser($hookData, ['vpn-admin-portal']); |
|
| 289 | ||
| 290 | $userId = InputValidation::userId($request->getPostParameter('user_id')); |
|
| 291 | ||
| 292 | $this->storage->disableUser($userId); |
|
| 293 | $this->storage->addUserMessage($userId, 'notification', 'account disabled'); |
|
| 294 | ||
| 295 | return new ApiResponse('disable_user'); |
|
| 296 | } |
|
| 297 | ); |
|
| 298 | ||
| @@ 301-309 (lines=9) @@ | ||
| 298 | ||
| 299 | $service->post( |
|
| 300 | '/enable_user', |
|
| 301 | function (Request $request, array $hookData) { |
|
| 302 | AuthUtils::requireUser($hookData, ['vpn-admin-portal']); |
|
| 303 | ||
| 304 | $userId = InputValidation::userId($request->getPostParameter('user_id')); |
|
| 305 | ||
| 306 | $this->storage->enableUser($userId); |
|
| 307 | $this->storage->addUserMessage($userId, 'notification', 'account (re)enabled'); |
|
| 308 | ||
| 309 | return new ApiResponse('enable_user'); |
|
| 310 | } |
|
| 311 | ); |
|
| 312 | ||
| @@ 315-321 (lines=7) @@ | ||
| 312 | ||
| 313 | $service->post( |
|
| 314 | '/delete_user', |
|
| 315 | function (Request $request, array $hookData) { |
|
| 316 | AuthUtils::requireUser($hookData, ['vpn-admin-portal']); |
|
| 317 | ||
| 318 | $userId = InputValidation::userId($request->getPostParameter('user_id')); |
|
| 319 | $this->storage->deleteUser($userId); |
|
| 320 | ||
| 321 | return new ApiResponse('delete_user'); |
|
| 322 | } |
|
| 323 | ); |
|
| 324 | ||