| @@ 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( |
|
| @@ 96-102 (lines=7) @@ | ||
| 93 | ||
| 94 | $service->post( |
|
| 95 | '/disable_client_certificate', |
|
| 96 | function (Request $request, array $hookData) { |
|
| 97 | AuthUtils::requireUser($hookData, ['vpn-user-portal', 'vpn-admin-portal']); |
|
| 98 | ||
| 99 | $commonName = InputValidation::commonName($request->getPostParameter('common_name')); |
|
| 100 | ||
| 101 | return new ApiResponse('disable_client_certificate', $this->storage->disableCertificate($commonName)); |
|
| 102 | } |
|
| 103 | ); |
|
| 104 | ||
| 105 | $service->post( |
|
| @@ 107-113 (lines=7) @@ | ||
| 104 | ||
| 105 | $service->post( |
|
| 106 | '/enable_client_certificate', |
|
| 107 | function (Request $request, array $hookData) { |
|
| 108 | AuthUtils::requireUser($hookData, ['vpn-admin-portal']); |
|
| 109 | ||
| 110 | $commonName = InputValidation::commonName($request->getPostParameter('common_name')); |
|
| 111 | ||
| 112 | return new ApiResponse('enable_client_certificate', $this->storage->enableCertificate($commonName)); |
|
| 113 | } |
|
| 114 | ); |
|
| 115 | ||
| 116 | $service->get( |
|
| @@ 118-124 (lines=7) @@ | ||
| 115 | ||
| 116 | $service->get( |
|
| 117 | '/list_client_certificates', |
|
| 118 | function (Request $request, array $hookData) { |
|
| 119 | AuthUtils::requireUser($hookData, ['vpn-user-portal', 'vpn-admin-portal']); |
|
| 120 | ||
| 121 | $userId = InputValidation::userId($request->getQueryParameter('user_id')); |
|
| 122 | ||
| 123 | return new ApiResponse('list_client_certificates', $this->storage->getCertificates($userId)); |
|
| 124 | } |
|
| 125 | ); |
|
| 126 | } |
|
| 127 | } |
|
| @@ 52-58 (lines=7) @@ | ||
| 49 | ||
| 50 | $service->post( |
|
| 51 | '/kill_client', |
|
| 52 | function (Request $request, array $hookData) { |
|
| 53 | AuthUtils::requireUser($hookData, ['vpn-admin-portal', 'vpn-user-portal']); |
|
| 54 | ||
| 55 | $commonName = InputValidation::commonName($request->getPostParameter('common_name')); |
|
| 56 | ||
| 57 | return new ApiResponse('kill_client', $this->serverManager->kill($commonName)); |
|
| 58 | } |
|
| 59 | ); |
|
| 60 | } |
|
| 61 | } |
|
| @@ 105-111 (lines=7) @@ | ||
| 102 | ||
| 103 | $service->get( |
|
| 104 | '/has_totp_secret', |
|
| 105 | function (Request $request, array $hookData) { |
|
| 106 | AuthUtils::requireUser($hookData, ['vpn-user-portal', 'vpn-admin-portal']); |
|
| 107 | ||
| 108 | $userId = InputValidation::userId($request->getQueryParameter('user_id')); |
|
| 109 | ||
| 110 | return new ApiResponse('has_totp_secret', $this->storage->hasTotpSecret($userId)); |
|
| 111 | } |
|
| 112 | ); |
|
| 113 | ||
| 114 | $service->post( |
|
| @@ 116-122 (lines=7) @@ | ||
| 113 | ||
| 114 | $service->post( |
|
| 115 | '/delete_totp_secret', |
|
| 116 | function (Request $request, array $hookData) { |
|
| 117 | AuthUtils::requireUser($hookData, ['vpn-admin-portal']); |
|
| 118 | ||
| 119 | $userId = InputValidation::userId($request->getPostParameter('user_id')); |
|
| 120 | ||
| 121 | return new ApiResponse('delete_totp_secret', ['ok' => $this->storage->deleteTotpSecret($userId)]); |
|
| 122 | } |
|
| 123 | ); |
|
| 124 | ||
| 125 | $service->post( |
|
| @@ 139-145 (lines=7) @@ | ||
| 136 | ||
| 137 | $service->post( |
|
| 138 | '/delete_voot_token', |
|
| 139 | function (Request $request, array $hookData) { |
|
| 140 | AuthUtils::requireUser($hookData, ['vpn-admin-portal']); |
|
| 141 | ||
| 142 | $userId = InputValidation::userId($request->getPostParameter('user_id')); |
|
| 143 | ||
| 144 | return new ApiResponse('delete_voot_token', ['ok' => $this->storage->deleteVootToken($userId)]); |
|
| 145 | } |
|
| 146 | ); |
|
| 147 | ||
| 148 | $service->get( |
|
| @@ 150-156 (lines=7) @@ | ||
| 147 | ||
| 148 | $service->get( |
|
| 149 | '/has_voot_token', |
|
| 150 | function (Request $request, array $hookData) { |
|
| 151 | AuthUtils::requireUser($hookData, ['vpn-user-portal', 'vpn-admin-portal']); |
|
| 152 | ||
| 153 | $userId = InputValidation::userId($request->getQueryParameter('user_id')); |
|
| 154 | ||
| 155 | return new ApiResponse('has_voot_token', $this->storage->hasVootToken($userId)); |
|
| 156 | } |
|
| 157 | ); |
|
| 158 | ||
| 159 | $service->get( |
|
| @@ 161-167 (lines=7) @@ | ||
| 158 | ||
| 159 | $service->get( |
|
| 160 | '/is_disabled_user', |
|
| 161 | function (Request $request, array $hookData) { |
|
| 162 | AuthUtils::requireUser($hookData, ['vpn-admin-portal', 'vpn-user-portal']); |
|
| 163 | ||
| 164 | $userId = InputValidation::userId($request->getQueryParameter('user_id')); |
|
| 165 | ||
| 166 | return new ApiResponse('is_disabled_user', $this->storage->isDisabledUser($userId)); |
|
| 167 | } |
|
| 168 | ); |
|
| 169 | ||
| 170 | $service->post( |
|
| @@ 172-178 (lines=7) @@ | ||
| 169 | ||
| 170 | $service->post( |
|
| 171 | '/disable_user', |
|
| 172 | function (Request $request, array $hookData) { |
|
| 173 | AuthUtils::requireUser($hookData, ['vpn-admin-portal']); |
|
| 174 | ||
| 175 | $userId = InputValidation::userId($request->getPostParameter('user_id')); |
|
| 176 | ||
| 177 | return new ApiResponse('disable_user', ['ok' => $this->storage->disableUser($userId)]); |
|
| 178 | } |
|
| 179 | ); |
|
| 180 | ||
| 181 | $service->post( |
|
| @@ 183-189 (lines=7) @@ | ||
| 180 | ||
| 181 | $service->post( |
|
| 182 | '/enable_user', |
|
| 183 | function (Request $request, array $hookData) { |
|
| 184 | AuthUtils::requireUser($hookData, ['vpn-admin-portal']); |
|
| 185 | ||
| 186 | $userId = InputValidation::userId($request->getPostParameter('user_id')); |
|
| 187 | ||
| 188 | return new ApiResponse('enable_user', ['ok' => $this->storage->enableUser($userId)]); |
|
| 189 | } |
|
| 190 | ); |
|
| 191 | ||
| 192 | $service->post( |
|
| @@ 194-200 (lines=7) @@ | ||
| 191 | ||
| 192 | $service->post( |
|
| 193 | '/delete_user', |
|
| 194 | function (Request $request, array $hookData) { |
|
| 195 | AuthUtils::requireUser($hookData, ['vpn-admin-portal']); |
|
| 196 | ||
| 197 | $userId = InputValidation::userId($request->getPostParameter('user_id')); |
|
| 198 | ||
| 199 | return new ApiResponse('delete_user', ['ok' => $this->storage->deleteUser($userId)]); |
|
| 200 | } |
|
| 201 | ); |
|
| 202 | ||
| 203 | $service->get( |
|