| @@ 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 | $service->get( |
|
| @@ 129-135 (lines=7) @@ | ||
| 126 | ||
| 127 | $service->get( |
|
| 128 | '/client_certificate_info', |
|
| 129 | function (Request $request, array $hookData) { |
|
| 130 | AuthUtils::requireUser($hookData, ['vpn-user-portal', 'vpn-admin-portal']); |
|
| 131 | ||
| 132 | $commonName = InputValidation::commonName($request->getQueryParameter('common_name')); |
|
| 133 | ||
| 134 | return new ApiResponse('client_certificate_info', $this->storage->getUserCertificateInfo($commonName)); |
|
| 135 | } |
|
| 136 | ); |
|
| 137 | } |
|
| 138 | } |
|
| @@ 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 | } |
|
| @@ 113-119 (lines=7) @@ | ||
| 110 | ||
| 111 | $service->get( |
|
| 112 | '/has_totp_secret', |
|
| 113 | function (Request $request, array $hookData) { |
|
| 114 | AuthUtils::requireUser($hookData, ['vpn-user-portal', 'vpn-admin-portal']); |
|
| 115 | ||
| 116 | $userId = InputValidation::userId($request->getQueryParameter('user_id')); |
|
| 117 | ||
| 118 | return new ApiResponse('has_totp_secret', $this->storage->hasTotpSecret($userId)); |
|
| 119 | } |
|
| 120 | ); |
|
| 121 | ||
| 122 | $service->post( |
|
| @@ 124-130 (lines=7) @@ | ||
| 121 | ||
| 122 | $service->post( |
|
| 123 | '/delete_totp_secret', |
|
| 124 | function (Request $request, array $hookData) { |
|
| 125 | AuthUtils::requireUser($hookData, ['vpn-admin-portal']); |
|
| 126 | ||
| 127 | $userId = InputValidation::userId($request->getPostParameter('user_id')); |
|
| 128 | ||
| 129 | return new ApiResponse('delete_totp_secret', $this->storage->deleteTotpSecret($userId)); |
|
| 130 | } |
|
| 131 | ); |
|
| 132 | ||
| 133 | $service->post( |
|
| @@ 147-153 (lines=7) @@ | ||
| 144 | ||
| 145 | $service->post( |
|
| 146 | '/delete_voot_token', |
|
| 147 | function (Request $request, array $hookData) { |
|
| 148 | AuthUtils::requireUser($hookData, ['vpn-admin-portal']); |
|
| 149 | ||
| 150 | $userId = InputValidation::userId($request->getPostParameter('user_id')); |
|
| 151 | ||
| 152 | return new ApiResponse('delete_voot_token', $this->storage->deleteVootToken($userId)); |
|
| 153 | } |
|
| 154 | ); |
|
| 155 | ||
| 156 | $service->get( |
|
| @@ 158-164 (lines=7) @@ | ||
| 155 | ||
| 156 | $service->get( |
|
| 157 | '/has_voot_token', |
|
| 158 | function (Request $request, array $hookData) { |
|
| 159 | AuthUtils::requireUser($hookData, ['vpn-user-portal', 'vpn-admin-portal']); |
|
| 160 | ||
| 161 | $userId = InputValidation::userId($request->getQueryParameter('user_id')); |
|
| 162 | ||
| 163 | return new ApiResponse('has_voot_token', $this->storage->hasVootToken($userId)); |
|
| 164 | } |
|
| 165 | ); |
|
| 166 | ||
| 167 | $service->get( |
|
| @@ 169-175 (lines=7) @@ | ||
| 166 | ||
| 167 | $service->get( |
|
| 168 | '/is_disabled_user', |
|
| 169 | function (Request $request, array $hookData) { |
|
| 170 | AuthUtils::requireUser($hookData, ['vpn-admin-portal', 'vpn-user-portal']); |
|
| 171 | ||
| 172 | $userId = InputValidation::userId($request->getQueryParameter('user_id')); |
|
| 173 | ||
| 174 | return new ApiResponse('is_disabled_user', $this->storage->isDisabledUser($userId)); |
|
| 175 | } |
|
| 176 | ); |
|
| 177 | ||
| 178 | $service->post( |
|
| @@ 180-186 (lines=7) @@ | ||
| 177 | ||
| 178 | $service->post( |
|
| 179 | '/disable_user', |
|
| 180 | function (Request $request, array $hookData) { |
|
| 181 | AuthUtils::requireUser($hookData, ['vpn-admin-portal']); |
|
| 182 | ||
| 183 | $userId = InputValidation::userId($request->getPostParameter('user_id')); |
|
| 184 | ||
| 185 | return new ApiResponse('disable_user', $this->storage->disableUser($userId)); |
|
| 186 | } |
|
| 187 | ); |
|
| 188 | ||
| 189 | $service->post( |
|
| @@ 202-208 (lines=7) @@ | ||
| 199 | ||
| 200 | $service->post( |
|
| 201 | '/delete_user', |
|
| 202 | function (Request $request, array $hookData) { |
|
| 203 | AuthUtils::requireUser($hookData, ['vpn-admin-portal']); |
|
| 204 | ||
| 205 | $userId = InputValidation::userId($request->getPostParameter('user_id')); |
|
| 206 | ||
| 207 | return new ApiResponse('delete_user', $this->storage->deleteUser($userId)); |
|
| 208 | } |
|
| 209 | ); |
|
| 210 | ||
| 211 | $service->get( |
|