Added authorization callback for '/logging/toggle'. This patch adds an authorization callback to the generating function `CreateAuthorizationCallbacks` for the '/logging/toggle' endpoint.
Review: https://reviews.apache.org/r/46881/ Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/1140f6e5 Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/1140f6e5 Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/1140f6e5 Branch: refs/heads/master Commit: 1140f6e5c3757034896ec9256a9d118c4331a361 Parents: a776785 Author: Greg Mann <[email protected]> Authored: Wed May 11 22:45:49 2016 -0400 Committer: Kapil Arya <[email protected]> Committed: Thu May 12 01:50:20 2016 -0400 ---------------------------------------------------------------------- src/common/http.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/1140f6e5/src/common/http.cpp ---------------------------------------------------------------------- diff --git a/src/common/http.cpp b/src/common/http.cpp index 798acf5..ad6a4b4 100644 --- a/src/common/http.cpp +++ b/src/common/http.cpp @@ -587,9 +587,13 @@ static void json(JSON::StringWriter* writer, const Value::Text& text) const AuthorizationCallbacks createAuthorizationCallbacks( Authorizer* authorizer) { + typedef lambda::function<process::Future<bool>( + const process::http::Request& httpRequest, + const Option<string>& principal)> Callback; + AuthorizationCallbacks callbacks; - callbacks.insert(std::make_pair("/metrics/snapshot", [authorizer]( + Callback getEndpoint = [authorizer]( const process::http::Request& httpRequest, const Option<string>& principal) -> process::Future<bool> { authorization::Request authRequest; @@ -607,7 +611,10 @@ const AuthorizationCallbacks createAuthorizationCallbacks( << "' to GET the endpoint '" << path << "'"; return authorizer->authorized(authRequest); - })); + }; + + callbacks.insert(std::make_pair("/logging/toggle", getEndpoint)); + callbacks.insert(std::make_pair("/metrics/snapshot", getEndpoint)); return callbacks; }
