| 346 | |
| 347 | |
| 348 | Future<bool> Master::WeightsHandler::authorizeGetWeight( |
| 349 | const Option<Principal>& principal, |
| 350 | const WeightInfo& weight) const |
| 351 | { |
| 352 | if (master->authorizer.isNone()) { |
| 353 | return true; |
| 354 | } |
| 355 | |
| 356 | LOG(INFO) << "Authorizing principal '" |
| 357 | << (principal.isSome() ? stringify(principal.get()) : "ANY") |
| 358 | << "' to get weight for role '" << weight.role() << "'"; |
| 359 | |
| 360 | authorization::Request request; |
| 361 | request.set_action(authorization::VIEW_ROLE); |
| 362 | |
| 363 | Option<authorization::Subject> subject = createSubject(principal); |
| 364 | if (subject.isSome()) { |
| 365 | request.mutable_subject()->CopyFrom(subject.get()); |
| 366 | } |
| 367 | |
| 368 | request.mutable_object()->mutable_weight_info()->CopyFrom(weight); |
| 369 | request.mutable_object()->set_value(weight.role()); |
| 370 | |
| 371 | return master->authorizer.get()->authorized(request); |
| 372 | } |
| 373 | |
| 374 | } // namespace master { |
| 375 | } // namespace internal { |
nothing calls this directly
no test coverage detected