grpc_authorization_engine.h
Go to the documentation of this file.
1 // Copyright 2021 gRPC authors.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef GRPC_CORE_LIB_SECURITY_AUTHORIZATION_GRPC_AUTHORIZATION_ENGINE_H
16 #define GRPC_CORE_LIB_SECURITY_AUTHORIZATION_GRPC_AUTHORIZATION_ENGINE_H
17 
19 
20 #include <stddef.h>
21 
22 #include <memory>
23 #include <string>
24 #include <vector>
25 
30 
31 namespace grpc_core {
32 
33 // GrpcAuthorizationEngine can be either an Allow engine or Deny engine. This
34 // engine makes authorization decisions to Allow or Deny incoming RPC request
35 // based on permission and principal configs in the provided RBAC policy and the
36 // engine type. This engine ignores condition field in RBAC config. It is the
37 // caller's responsibility to provide RBAC policies that are compatible with
38 // this engine.
40  public:
41  // Builds GrpcAuthorizationEngine without any policies.
43  // Builds GrpcAuthorizationEngine with allow/deny RBAC policy.
44  explicit GrpcAuthorizationEngine(Rbac policy);
45 
48 
49  Rbac::Action action() const { return action_; }
50 
51  // Required only for testing purpose.
52  size_t num_policies() const { return policies_.size(); }
53 
54  // Evaluates incoming request against RBAC policy and makes a decision to
55  // whether allow/deny this request.
56  Decision Evaluate(const EvaluateArgs& args) const override;
57 
58  private:
59  struct Policy {
61  std::unique_ptr<AuthorizationMatcher> matcher;
62  };
64  std::vector<Policy> policies_;
65 };
66 
67 } // namespace grpc_core
68 
69 #endif // GRPC_CORE_LIB_SECURITY_AUTHORIZATION_GRPC_AUTHORIZATION_ENGINE_H
grpc_core::EvaluateArgs
Definition: evaluate_args.h:34
grpc_core::GrpcAuthorizationEngine::Policy::matcher
std::unique_ptr< AuthorizationMatcher > matcher
Definition: grpc_authorization_engine.h:61
grpc_core::GrpcAuthorizationEngine::num_policies
size_t num_policies() const
Definition: grpc_authorization_engine.h:52
grpc_core
Definition: call_metric_recorder.h:31
testing::internal::string
::std::string string
Definition: bloaty/third_party/protobuf/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:881
authorization_engine.h
grpc_core::GrpcAuthorizationEngine::GrpcAuthorizationEngine
GrpcAuthorizationEngine(Rbac::Action action)
Definition: grpc_authorization_engine.h:42
grpc_core::GrpcAuthorizationEngine::operator=
GrpcAuthorizationEngine & operator=(GrpcAuthorizationEngine &&other) noexcept
Definition: grpc_authorization_engine.cc:42
grpc_core::GrpcAuthorizationEngine
Definition: grpc_authorization_engine.h:39
evaluate_args.h
asyncio_get_stats.args
args
Definition: asyncio_get_stats.py:40
grpc_core::Rbac::Action
Action
Definition: rbac_policy.h:36
matchers.h
rbac_policy.h
grpc_core::GrpcAuthorizationEngine::Policy
Definition: grpc_authorization_engine.h:59
grpc_core::GrpcAuthorizationEngine::Evaluate
Decision Evaluate(const EvaluateArgs &args) const override
Definition: grpc_authorization_engine.cc:49
grpc_core::GrpcAuthorizationEngine::action_
Rbac::Action action_
Definition: grpc_authorization_engine.h:63
grpc_core::Rbac
Definition: rbac_policy.h:35
grpc_core::GrpcAuthorizationEngine::policies_
std::vector< Policy > policies_
Definition: grpc_authorization_engine.h:64
grpc_core::AuthorizationEngine
Definition: authorization_engine.h:28
grpc_core::GrpcAuthorizationEngine::action
Rbac::Action action() const
Definition: grpc_authorization_engine.h:49
grpc_core::GrpcAuthorizationEngine::Policy::name
std::string name
Definition: grpc_authorization_engine.h:60
port_platform.h


grpc
Author(s):
autogenerated on Thu Mar 13 2025 02:59:47