| @@ 98-105 (lines=8) @@ | ||
| 95 | ||
| 96 | $service->post( |
|
| 97 | '/disable_client_certificate', |
|
| 98 | function (Request $request, array $hookData) { |
|
| 99 | AuthUtils::requireUser($hookData, ['vpn-user-portal', 'vpn-admin-portal']); |
|
| 100 | ||
| 101 | $commonName = $request->getPostParameter('common_name'); |
|
| 102 | InputValidation::commonName($commonName); |
|
| 103 | ||
| 104 | return new ApiResponse('disable_client_certificate', $this->storage->disableCertificate($commonName)); |
|
| 105 | } |
|
| 106 | ); |
|
| 107 | ||
| 108 | $service->post( |
|
| @@ 110-117 (lines=8) @@ | ||
| 107 | ||
| 108 | $service->post( |
|
| 109 | '/enable_client_certificate', |
|
| 110 | function (Request $request, array $hookData) { |
|
| 111 | AuthUtils::requireUser($hookData, ['vpn-admin-portal']); |
|
| 112 | ||
| 113 | $commonName = $request->getPostParameter('common_name'); |
|
| 114 | InputValidation::commonName($commonName); |
|
| 115 | ||
| 116 | return new ApiResponse('enable_client_certificate', $this->storage->enableCertificate($commonName)); |
|
| 117 | } |
|
| 118 | ); |
|
| 119 | ||
| 120 | $service->get( |
|
| @@ 122-129 (lines=8) @@ | ||
| 119 | ||
| 120 | $service->get( |
|
| 121 | '/list_client_certificates', |
|
| 122 | function (Request $request, array $hookData) { |
|
| 123 | AuthUtils::requireUser($hookData, ['vpn-user-portal', 'vpn-admin-portal']); |
|
| 124 | ||
| 125 | $userId = $request->getQueryParameter('user_id'); |
|
| 126 | InputValidation::userId($userId); |
|
| 127 | ||
| 128 | return new ApiResponse('list_client_certificates', $this->storage->getCertificates($userId)); |
|
| 129 | } |
|
| 130 | ); |
|
| 131 | } |
|
| 132 | } |
|
| @@ 51-61 (lines=11) @@ | ||
| 48 | ||
| 49 | $service->post( |
|
| 50 | '/set_motd', |
|
| 51 | function (Request $request, array $hookData) { |
|
| 52 | AuthUtils::requireUser($hookData, ['vpn-admin-portal']); |
|
| 53 | ||
| 54 | // we do NOT sanitize or verify motd_message as *everything* |
|
| 55 | // is allowed! It will never be used as-is for showing in the |
|
| 56 | // browser, as the user portal will escape it before showing |
|
| 57 | // and the apps MUST interprete it as "text/plain". |
|
| 58 | $motdMessage = $request->getPostParameter('motd_message'); |
|
| 59 | ||
| 60 | return new ApiResponse('set_motd', $this->storage->setMotd($motdMessage)); |
|
| 61 | } |
|
| 62 | ); |
|
| 63 | ||
| 64 | $service->post( |
|
| @@ 51-58 (lines=8) @@ | ||
| 48 | ||
| 49 | $service->post( |
|
| 50 | '/kill_client', |
|
| 51 | function (Request $request, array $hookData) { |
|
| 52 | AuthUtils::requireUser($hookData, ['vpn-admin-portal', 'vpn-user-portal']); |
|
| 53 | ||
| 54 | $commonName = $request->getPostParameter('common_name'); |
|
| 55 | InputValidation::commonName($commonName); |
|
| 56 | ||
| 57 | return new ApiResponse('kill_client', $this->serverManager->kill($commonName)); |
|
| 58 | } |
|
| 59 | ); |
|
| 60 | } |
|
| 61 | } |
|
| @@ 109-116 (lines=8) @@ | ||
| 106 | ||
| 107 | $service->get( |
|
| 108 | '/has_totp_secret', |
|
| 109 | function (Request $request, array $hookData) { |
|
| 110 | AuthUtils::requireUser($hookData, ['vpn-user-portal', 'vpn-admin-portal']); |
|
| 111 | ||
| 112 | $userId = $request->getQueryParameter('user_id'); |
|
| 113 | InputValidation::userId($userId); |
|
| 114 | ||
| 115 | return new ApiResponse('has_totp_secret', $this->storage->hasTotpSecret($userId)); |
|
| 116 | } |
|
| 117 | ); |
|
| 118 | ||
| 119 | $service->post( |
|
| @@ 121-128 (lines=8) @@ | ||
| 118 | ||
| 119 | $service->post( |
|
| 120 | '/delete_totp_secret', |
|
| 121 | function (Request $request, array $hookData) { |
|
| 122 | AuthUtils::requireUser($hookData, ['vpn-admin-portal']); |
|
| 123 | ||
| 124 | $userId = $request->getPostParameter('user_id'); |
|
| 125 | InputValidation::userId($userId); |
|
| 126 | ||
| 127 | return new ApiResponse('delete_totp_secret', ['ok' => $this->storage->deleteTotpSecret($userId)]); |
|
| 128 | } |
|
| 129 | ); |
|
| 130 | ||
| 131 | $service->post( |
|
| @@ 147-154 (lines=8) @@ | ||
| 144 | ||
| 145 | $service->post( |
|
| 146 | '/delete_voot_token', |
|
| 147 | function (Request $request, array $hookData) { |
|
| 148 | AuthUtils::requireUser($hookData, ['vpn-admin-portal']); |
|
| 149 | ||
| 150 | $userId = $request->getPostParameter('user_id'); |
|
| 151 | InputValidation::userId($userId); |
|
| 152 | ||
| 153 | return new ApiResponse('delete_voot_token', ['ok' => $this->storage->deleteVootToken($userId)]); |
|
| 154 | } |
|
| 155 | ); |
|
| 156 | ||
| 157 | $service->get( |
|
| @@ 159-166 (lines=8) @@ | ||
| 156 | ||
| 157 | $service->get( |
|
| 158 | '/is_disabled_user', |
|
| 159 | function (Request $request, array $hookData) { |
|
| 160 | AuthUtils::requireUser($hookData, ['vpn-admin-portal', 'vpn-user-portal']); |
|
| 161 | ||
| 162 | $userId = $request->getQueryParameter('user_id'); |
|
| 163 | InputValidation::userId($userId); |
|
| 164 | ||
| 165 | return new ApiResponse('is_disabled_user', $this->storage->isDisabledUser($userId)); |
|
| 166 | } |
|
| 167 | ); |
|
| 168 | ||
| 169 | $service->post( |
|
| @@ 171-178 (lines=8) @@ | ||
| 168 | ||
| 169 | $service->post( |
|
| 170 | '/disable_user', |
|
| 171 | function (Request $request, array $hookData) { |
|
| 172 | AuthUtils::requireUser($hookData, ['vpn-admin-portal']); |
|
| 173 | ||
| 174 | $userId = $request->getPostParameter('user_id'); |
|
| 175 | InputValidation::userId($userId); |
|
| 176 | ||
| 177 | return new ApiResponse('disable_user', ['ok' => $this->storage->disableUser($userId)]); |
|
| 178 | } |
|
| 179 | ); |
|
| 180 | ||
| 181 | $service->post( |
|
| @@ 183-190 (lines=8) @@ | ||
| 180 | ||
| 181 | $service->post( |
|
| 182 | '/enable_user', |
|
| 183 | function (Request $request, array $hookData) { |
|
| 184 | AuthUtils::requireUser($hookData, ['vpn-admin-portal']); |
|
| 185 | ||
| 186 | $userId = $request->getPostParameter('user_id'); |
|
| 187 | InputValidation::userId($userId); |
|
| 188 | ||
| 189 | return new ApiResponse('enable_user', ['ok' => $this->storage->enableUser($userId)]); |
|
| 190 | } |
|
| 191 | ); |
|
| 192 | ||
| 193 | $service->post( |
|
| @@ 195-202 (lines=8) @@ | ||
| 192 | ||
| 193 | $service->post( |
|
| 194 | '/delete_user', |
|
| 195 | function (Request $request, array $hookData) { |
|
| 196 | AuthUtils::requireUser($hookData, ['vpn-admin-portal']); |
|
| 197 | ||
| 198 | $userId = $request->getPostParameter('user_id'); |
|
| 199 | InputValidation::userId($userId); |
|
| 200 | ||
| 201 | return new ApiResponse('delete_user', ['ok' => $this->storage->deleteUser($userId)]); |
|
| 202 | } |
|
| 203 | ); |
|
| 204 | ||
| 205 | $service->get( |
|