| 922 | |
| 923 | |
| 924 | Future<Response> Http::flags( |
| 925 | const Request& request, |
| 926 | const Option<Principal>& principal) const |
| 927 | { |
| 928 | // TODO(nfnt): Remove check for enabled |
| 929 | // authorization as part of MESOS-5346. |
| 930 | if (request.method != "GET" && slave->authorizer.isSome()) { |
| 931 | return MethodNotAllowed({"GET"}, request.method); |
| 932 | } |
| 933 | |
| 934 | if (slave->authorizer.isNone()) { |
| 935 | return OK(_flags(), request.url.query.get("jsonp")); |
| 936 | } |
| 937 | |
| 938 | authorization::Request authRequest; |
| 939 | authRequest.set_action(authorization::VIEW_FLAGS); |
| 940 | |
| 941 | Option<authorization::Subject> subject = createSubject(principal); |
| 942 | if (subject.isSome()) { |
| 943 | authRequest.mutable_subject()->CopyFrom(subject.get()); |
| 944 | } |
| 945 | |
| 946 | return slave->authorizer.get()->authorized(authRequest) |
| 947 | .then(defer( |
| 948 | slave->self(), |
| 949 | [this, request](bool authorized) -> Future<Response> { |
| 950 | if (authorized) { |
| 951 | return OK(_flags(), request.url.query.get("jsonp")); |
| 952 | } else { |
| 953 | return Forbidden(); |
| 954 | } |
| 955 | })); |
| 956 | } |
| 957 | |
| 958 | |
| 959 | JSON::Object Http::_flags() const |
no test coverage detected