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

Method authorizeUpdateWeights

src/master/weights_handler.cpp:313–345  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

311
312
313Future<bool> Master::WeightsHandler::authorizeUpdateWeights(
314 const Option<Principal>& principal,
315 const vector<string>& roles) const
316{
317 if (master->authorizer.isNone()) {
318 return true;
319 }
320
321 LOG(INFO) << "Authorizing principal '"
322 << (principal.isSome() ? stringify(principal.get()) : "ANY")
323 << "' to update weights for roles '" << stringify(roles) << "'";
324
325 authorization::Request request;
326 request.set_action(authorization::UPDATE_WEIGHT);
327
328 Option<authorization::Subject> subject = createSubject(principal);
329 if (subject.isSome()) {
330 request.mutable_subject()->CopyFrom(subject.get());
331 }
332
333 vector<Future<bool>> authorizations;
334 authorizations.reserve(roles.size());
335 foreach (const string& role, roles) {
336 request.mutable_object()->set_value(role);
337 authorizations.push_back(master->authorizer.get()->authorized(request));
338 }
339
340 if (authorizations.empty()) {
341 return master->authorizer.get()->authorized(request);
342 }
343
344 return authorization::collectAuthorizations(authorizations);
345}
346
347
348Future<bool> Master::WeightsHandler::authorizeGetWeight(

Callers

nothing calls this directly

Calls 11

createSubjectFunction · 0.85
collectAuthorizationsFunction · 0.85
CopyFromMethod · 0.80
stringifyFunction · 0.50
isNoneMethod · 0.45
isSomeMethod · 0.45
getMethod · 0.45
reserveMethod · 0.45
sizeMethod · 0.45
emptyMethod · 0.45
authorizedMethod · 0.45

Tested by

no test coverage detected