| 2908 | |
| 2909 | |
| 2910 | Future<Response> Master::Http::tasks( |
| 2911 | const Request& request, |
| 2912 | const Option<Principal>& principal) const |
| 2913 | { |
| 2914 | // TODO(greggomann): Remove this check once the `Principal` type is used in |
| 2915 | // `ReservationInfo`, `DiskInfo`, and within the master's `principals` map. |
| 2916 | // See MESOS-7202. |
| 2917 | if (principal.isSome() && principal->value.isNone()) { |
| 2918 | return Forbidden( |
| 2919 | "The request's authenticated principal contains claims, but no value " |
| 2920 | "string. The master currently requires that principals have a value"); |
| 2921 | } |
| 2922 | |
| 2923 | // When current master is not the leader, redirect to the leading master. |
| 2924 | if (!master->elected()) { |
| 2925 | return redirect(request); |
| 2926 | } |
| 2927 | |
| 2928 | return ObjectApprovers::create( |
| 2929 | master->authorizer, |
| 2930 | principal, |
| 2931 | {VIEW_FRAMEWORK, VIEW_TASK}) |
| 2932 | .then(defer( |
| 2933 | master->self(), |
| 2934 | [this, request, principal](const Owned<ObjectApprovers>& approvers) { |
| 2935 | return deferBatchedRequest( |
| 2936 | &Master::ReadOnlyHandler::tasks, |
| 2937 | principal, |
| 2938 | ContentType::JSON, |
| 2939 | request.url.query, |
| 2940 | approvers); |
| 2941 | })); |
| 2942 | } |
| 2943 | |
| 2944 | |
| 2945 | Future<Response> Master::Http::getTasks( |