| @@ 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 | } |
|
| @@ 108-114 (lines=7) @@ | ||
| 105 | ||
| 106 | $service->get( |
|
| 107 | '/has_totp_secret', |
|
| 108 | function (Request $request, array $hookData) { |
|
| 109 | AuthUtils::requireUser($hookData, ['vpn-user-portal', 'vpn-admin-portal']); |
|
| 110 | ||
| 111 | $userId = InputValidation::userId($request->getQueryParameter('user_id')); |
|
| 112 | ||
| 113 | return new ApiResponse('has_totp_secret', $this->storage->hasTotpSecret($userId)); |
|
| 114 | } |
|
| 115 | ); |
|
| 116 | ||
| 117 | $service->post( |
|
| @@ 119-125 (lines=7) @@ | ||
| 116 | ||
| 117 | $service->post( |
|
| 118 | '/delete_totp_secret', |
|
| 119 | function (Request $request, array $hookData) { |
|
| 120 | AuthUtils::requireUser($hookData, ['vpn-admin-portal']); |
|
| 121 | ||
| 122 | $userId = InputValidation::userId($request->getPostParameter('user_id')); |
|
| 123 | ||
| 124 | return new ApiResponse('delete_totp_secret', $this->storage->deleteTotpSecret($userId)); |
|
| 125 | } |
|
| 126 | ); |
|
| 127 | ||
| 128 | $service->post( |
|
| @@ 142-148 (lines=7) @@ | ||
| 139 | ||
| 140 | $service->post( |
|
| 141 | '/delete_voot_token', |
|
| 142 | function (Request $request, array $hookData) { |
|
| 143 | AuthUtils::requireUser($hookData, ['vpn-admin-portal']); |
|
| 144 | ||
| 145 | $userId = InputValidation::userId($request->getPostParameter('user_id')); |
|
| 146 | ||
| 147 | return new ApiResponse('delete_voot_token', $this->storage->deleteVootToken($userId)); |
|
| 148 | } |
|
| 149 | ); |
|
| 150 | ||
| 151 | $service->get( |
|
| @@ 153-159 (lines=7) @@ | ||
| 150 | ||
| 151 | $service->get( |
|
| 152 | '/has_voot_token', |
|
| 153 | function (Request $request, array $hookData) { |
|
| 154 | AuthUtils::requireUser($hookData, ['vpn-user-portal', 'vpn-admin-portal']); |
|
| 155 | ||
| 156 | $userId = InputValidation::userId($request->getQueryParameter('user_id')); |
|
| 157 | ||
| 158 | return new ApiResponse('has_voot_token', $this->storage->hasVootToken($userId)); |
|
| 159 | } |
|
| 160 | ); |
|
| 161 | ||
| 162 | $service->get( |
|
| @@ 164-170 (lines=7) @@ | ||
| 161 | ||
| 162 | $service->get( |
|
| 163 | '/is_disabled_user', |
|
| 164 | function (Request $request, array $hookData) { |
|
| 165 | AuthUtils::requireUser($hookData, ['vpn-admin-portal', 'vpn-user-portal']); |
|
| 166 | ||
| 167 | $userId = InputValidation::userId($request->getQueryParameter('user_id')); |
|
| 168 | ||
| 169 | return new ApiResponse('is_disabled_user', $this->storage->isDisabledUser($userId)); |
|
| 170 | } |
|
| 171 | ); |
|
| 172 | ||
| 173 | $service->post( |
|
| @@ 175-181 (lines=7) @@ | ||
| 172 | ||
| 173 | $service->post( |
|
| 174 | '/disable_user', |
|
| 175 | function (Request $request, array $hookData) { |
|
| 176 | AuthUtils::requireUser($hookData, ['vpn-admin-portal']); |
|
| 177 | ||
| 178 | $userId = InputValidation::userId($request->getPostParameter('user_id')); |
|
| 179 | ||
| 180 | return new ApiResponse('disable_user', $this->storage->disableUser($userId)); |
|
| 181 | } |
|
| 182 | ); |
|
| 183 | ||
| 184 | $service->post( |
|
| @@ 197-203 (lines=7) @@ | ||
| 194 | ||
| 195 | $service->post( |
|
| 196 | '/delete_user', |
|
| 197 | function (Request $request, array $hookData) { |
|
| 198 | AuthUtils::requireUser($hookData, ['vpn-admin-portal']); |
|
| 199 | ||
| 200 | $userId = InputValidation::userId($request->getPostParameter('user_id')); |
|
| 201 | ||
| 202 | return new ApiResponse('delete_user', $this->storage->deleteUser($userId)); |
|
| 203 | } |
|
| 204 | ); |
|
| 205 | ||
| 206 | $service->get( |
|