| @@ 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 | } |
|
| @@ 96-102 (lines=7) @@ | ||
| 93 | ||
| 94 | $service->post( |
|
| 95 | '/delete_client_certificate', |
|
| 96 | function (Request $request, array $hookData) { |
|
| 97 | AuthUtils::requireUser($hookData, ['vpn-user-portal']); |
|
| 98 | ||
| 99 | $commonName = InputValidation::commonName($request->getPostParameter('common_name')); |
|
| 100 | ||
| 101 | return new ApiResponse('delete_client_certificate', $this->storage->deleteCertificate($commonName)); |
|
| 102 | } |
|
| 103 | ); |
|
| 104 | ||
| 105 | $service->post( |
|
| @@ 107-113 (lines=7) @@ | ||
| 104 | ||
| 105 | $service->post( |
|
| 106 | '/disable_client_certificate', |
|
| 107 | function (Request $request, array $hookData) { |
|
| 108 | AuthUtils::requireUser($hookData, ['vpn-user-portal', 'vpn-admin-portal']); |
|
| 109 | ||
| 110 | $commonName = InputValidation::commonName($request->getPostParameter('common_name')); |
|
| 111 | ||
| 112 | return new ApiResponse('disable_client_certificate', $this->storage->disableCertificate($commonName)); |
|
| 113 | } |
|
| 114 | ); |
|
| 115 | ||
| 116 | $service->post( |
|
| @@ 118-124 (lines=7) @@ | ||
| 115 | ||
| 116 | $service->post( |
|
| 117 | '/enable_client_certificate', |
|
| 118 | function (Request $request, array $hookData) { |
|
| 119 | AuthUtils::requireUser($hookData, ['vpn-admin-portal']); |
|
| 120 | ||
| 121 | $commonName = InputValidation::commonName($request->getPostParameter('common_name')); |
|
| 122 | ||
| 123 | return new ApiResponse('enable_client_certificate', $this->storage->enableCertificate($commonName)); |
|
| 124 | } |
|
| 125 | ); |
|
| 126 | ||
| 127 | $service->get( |
|
| @@ 129-135 (lines=7) @@ | ||
| 126 | ||
| 127 | $service->get( |
|
| 128 | '/client_certificate_list', |
|
| 129 | function (Request $request, array $hookData) { |
|
| 130 | AuthUtils::requireUser($hookData, ['vpn-user-portal', 'vpn-admin-portal']); |
|
| 131 | ||
| 132 | $userId = InputValidation::userId($request->getQueryParameter('user_id')); |
|
| 133 | ||
| 134 | return new ApiResponse('client_certificate_list', $this->storage->getCertificates($userId)); |
|
| 135 | } |
|
| 136 | ); |
|
| 137 | ||
| 138 | $service->get( |
|
| @@ 140-146 (lines=7) @@ | ||
| 137 | ||
| 138 | $service->get( |
|
| 139 | '/client_certificate_info', |
|
| 140 | function (Request $request, array $hookData) { |
|
| 141 | AuthUtils::requireUser($hookData, ['vpn-user-portal', 'vpn-admin-portal']); |
|
| 142 | ||
| 143 | $commonName = InputValidation::commonName($request->getQueryParameter('common_name')); |
|
| 144 | ||
| 145 | return new ApiResponse('client_certificate_info', $this->storage->getUserCertificateInfo($commonName)); |
|
| 146 | } |
|
| 147 | ); |
|
| 148 | } |
|
| 149 | } |
|
| @@ 100-106 (lines=7) @@ | ||
| 97 | ||
| 98 | $service->get( |
|
| 99 | '/has_totp_secret', |
|
| 100 | function (Request $request, array $hookData) { |
|
| 101 | AuthUtils::requireUser($hookData, ['vpn-user-portal', 'vpn-admin-portal']); |
|
| 102 | ||
| 103 | $userId = InputValidation::userId($request->getQueryParameter('user_id')); |
|
| 104 | ||
| 105 | return new ApiResponse('has_totp_secret', $this->storage->hasTotpSecret($userId)); |
|
| 106 | } |
|
| 107 | ); |
|
| 108 | ||
| 109 | $service->post( |
|
| @@ 111-117 (lines=7) @@ | ||
| 108 | ||
| 109 | $service->post( |
|
| 110 | '/delete_totp_secret', |
|
| 111 | function (Request $request, array $hookData) { |
|
| 112 | AuthUtils::requireUser($hookData, ['vpn-admin-portal']); |
|
| 113 | ||
| 114 | $userId = InputValidation::userId($request->getPostParameter('user_id')); |
|
| 115 | ||
| 116 | return new ApiResponse('delete_totp_secret', $this->storage->deleteTotpSecret($userId)); |
|
| 117 | } |
|
| 118 | ); |
|
| 119 | ||
| 120 | $service->post( |
|
| @@ 134-140 (lines=7) @@ | ||
| 131 | ||
| 132 | $service->post( |
|
| 133 | '/delete_voot_token', |
|
| 134 | function (Request $request, array $hookData) { |
|
| 135 | AuthUtils::requireUser($hookData, ['vpn-admin-portal']); |
|
| 136 | ||
| 137 | $userId = InputValidation::userId($request->getPostParameter('user_id')); |
|
| 138 | ||
| 139 | return new ApiResponse('delete_voot_token', $this->storage->deleteVootToken($userId)); |
|
| 140 | } |
|
| 141 | ); |
|
| 142 | ||
| 143 | $service->get( |
|
| @@ 145-151 (lines=7) @@ | ||
| 142 | ||
| 143 | $service->get( |
|
| 144 | '/has_voot_token', |
|
| 145 | function (Request $request, array $hookData) { |
|
| 146 | AuthUtils::requireUser($hookData, ['vpn-user-portal', 'vpn-admin-portal']); |
|
| 147 | ||
| 148 | $userId = InputValidation::userId($request->getQueryParameter('user_id')); |
|
| 149 | ||
| 150 | return new ApiResponse('has_voot_token', $this->storage->hasVootToken($userId)); |
|
| 151 | } |
|
| 152 | ); |
|
| 153 | ||
| 154 | $service->get( |
|
| @@ 156-162 (lines=7) @@ | ||
| 153 | ||
| 154 | $service->get( |
|
| 155 | '/is_disabled_user', |
|
| 156 | function (Request $request, array $hookData) { |
|
| 157 | AuthUtils::requireUser($hookData, ['vpn-admin-portal', 'vpn-user-portal']); |
|
| 158 | ||
| 159 | $userId = InputValidation::userId($request->getQueryParameter('user_id')); |
|
| 160 | ||
| 161 | return new ApiResponse('is_disabled_user', $this->storage->isDisabledUser($userId)); |
|
| 162 | } |
|
| 163 | ); |
|
| 164 | ||
| 165 | $service->post( |
|
| @@ 167-173 (lines=7) @@ | ||
| 164 | ||
| 165 | $service->post( |
|
| 166 | '/disable_user', |
|
| 167 | function (Request $request, array $hookData) { |
|
| 168 | AuthUtils::requireUser($hookData, ['vpn-admin-portal']); |
|
| 169 | ||
| 170 | $userId = InputValidation::userId($request->getPostParameter('user_id')); |
|
| 171 | ||
| 172 | return new ApiResponse('disable_user', $this->storage->disableUser($userId)); |
|
| 173 | } |
|
| 174 | ); |
|
| 175 | ||
| 176 | $service->post( |
|
| @@ 189-195 (lines=7) @@ | ||
| 186 | ||
| 187 | $service->post( |
|
| 188 | '/delete_user', |
|
| 189 | function (Request $request, array $hookData) { |
|
| 190 | AuthUtils::requireUser($hookData, ['vpn-admin-portal']); |
|
| 191 | ||
| 192 | $userId = InputValidation::userId($request->getPostParameter('user_id')); |
|
| 193 | ||
| 194 | return new ApiResponse('delete_user', $this->storage->deleteUser($userId)); |
|
| 195 | } |
|
| 196 | ); |
|
| 197 | ||
| 198 | $service->get( |
|
| @@ 48-54 (lines=7) @@ | ||
| 45 | { |
|
| 46 | $service->get( |
|
| 47 | '/system_messages', |
|
| 48 | function (Request $request, array $hookData) { |
|
| 49 | AuthUtils::requireUser($hookData, ['vpn-admin-portal', 'vpn-user-portal']); |
|
| 50 | ||
| 51 | $type = InputValidation::messageType($request->getQueryParameter('message_type')); |
|
| 52 | ||
| 53 | return new ApiResponse('system_messages', $this->storage->systemMessages($type)); |
|
| 54 | } |
|
| 55 | ); |
|
| 56 | ||
| 57 | $service->post( |
|
| @@ 76-82 (lines=7) @@ | ||
| 73 | ||
| 74 | $service->post( |
|
| 75 | '/delete_system_message', |
|
| 76 | function (Request $request, array $hookData) { |
|
| 77 | AuthUtils::requireUser($hookData, ['vpn-admin-portal']); |
|
| 78 | ||
| 79 | $messageId = InputValidation::messageId($request->getPostParameter('message_id')); |
|
| 80 | ||
| 81 | return new ApiResponse('delete_system_message', $this->storage->deleteSystemMessage($messageId)); |
|
| 82 | } |
|
| 83 | ); |
|
| 84 | } |
|
| 85 | } |
|