| 311 | |
| 312 | |
| 313 | Future<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 | |
| 348 | Future<bool> Master::WeightsHandler::authorizeGetWeight( |
nothing calls this directly
no test coverage detected