| @@ 102-119 (lines=18) @@ | ||
| 99 | ||
| 100 | $service->post( |
|
| 101 | '/ccd/disable', |
|
| 102 | function (Request $request, UserInfoInterface $userInfo) { |
|
| 103 | $commonName = $request->getPostParameter('common_name'); |
|
| 104 | if (is_null($commonName)) { |
|
| 105 | throw new BadRequestException('missing common_name'); |
|
| 106 | } |
|
| 107 | Utils::validateCommonName($commonName); |
|
| 108 | ||
| 109 | // $this->logInfo('disabling cn', array('api_user' => $userInfo->getUserId(), 'cn' => $commonName)); |
|
| 110 | ||
| 111 | $response = new JsonResponse(); |
|
| 112 | $response->setBody( |
|
| 113 | array( |
|
| 114 | 'ok' => $this->staticConfig->disableCommonName($commonName), |
|
| 115 | ) |
|
| 116 | ); |
|
| 117 | ||
| 118 | return $response; |
|
| 119 | } |
|
| 120 | ); |
|
| 121 | ||
| 122 | $service->delete( |
|
| @@ 143-160 (lines=18) @@ | ||
| 140 | ||
| 141 | $service->get( |
|
| 142 | '/ccd/disable', |
|
| 143 | function (Request $request, UserInfoInterface $userInfo) { |
|
| 144 | // we typically deal with CNs, not user IDs, but the part of |
|
| 145 | // the CN before the first '_' is considered the user ID |
|
| 146 | $userId = $request->getUrl()->getQueryParameter('user_id'); |
|
| 147 | if (!is_null($userId)) { |
|
| 148 | Utils::validateUserId($userId); |
|
| 149 | } |
|
| 150 | ||
| 151 | $response = new JsonResponse(); |
|
| 152 | $response->setBody( |
|
| 153 | array( |
|
| 154 | 'ok' => true, |
|
| 155 | 'disabled' => $this->staticConfig->getDisabledCommonNames($userId), |
|
| 156 | ) |
|
| 157 | ); |
|
| 158 | ||
| 159 | return $response; |
|
| 160 | } |
|
| 161 | ); |
|
| 162 | } |
|
| 163 | } |
|