MCPcopy Create free account
hub / github.com/apache/mesos / authorizeEndpoint

Function authorizeEndpoint

src/common/http.cpp:1240–1279  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1238
1239
1240process::Future<bool> authorizeEndpoint(
1241 const string& endpoint,
1242 const string& method,
1243 const Option<Authorizer*>& authorizer,
1244 const Option<Principal>& principal)
1245{
1246 if (authorizer.isNone()) {
1247 return true;
1248 }
1249
1250 authorization::Request request;
1251
1252 // TODO(nfnt): Add an additional case when POST requests
1253 // need to be authorized separately from GET requests.
1254 if (method == "GET") {
1255 request.set_action(authorization::GET_ENDPOINT_WITH_PATH);
1256 } else {
1257 return Failure("Unexpected request method '" + method + "'");
1258 }
1259
1260 if (!authorization::AUTHORIZABLE_ENDPOINTS.contains(endpoint)) {
1261 return Failure(
1262 "Endpoint '" + endpoint + "' is not an authorizable endpoint.");
1263 }
1264
1265 Option<authorization::Subject> subject =
1266 authorization::createSubject(principal);
1267 if (subject.isSome()) {
1268 request.mutable_subject()->CopyFrom(subject.get());
1269 }
1270
1271 request.mutable_object()->set_value(endpoint);
1272
1273 LOG(INFO) << "Authorizing principal '"
1274 << (principal.isSome() ? stringify(principal.get()) : "ANY")
1275 << "' to " << method
1276 << " the '" << endpoint << "' endpoint";
1277
1278 return authorizer.get()->authorized(request);
1279}
1280
1281
1282namespace {

Callers 4

debugMethod · 0.85
statisticsMethod · 0.85
containersMethod · 0.85
containerizerDebugMethod · 0.85

Calls 9

FailureClass · 0.85
createSubjectFunction · 0.85
CopyFromMethod · 0.80
stringifyFunction · 0.50
isNoneMethod · 0.45
containsMethod · 0.45
isSomeMethod · 0.45
getMethod · 0.45
authorizedMethod · 0.45

Tested by

no test coverage detected