rbac_service_config_parser.h
Go to the documentation of this file.
1 //
2 // Copyright 2021 gRPC authors.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16 
17 #ifndef GRPC_CORE_EXT_FILTERS_RBAC_RBAC_SERVICE_CONFIG_PARSER_H
18 #define GRPC_CORE_EXT_FILTERS_RBAC_RBAC_SERVICE_CONFIG_PARSER_H
19 
21 
22 #include <stddef.h>
23 
24 #include <algorithm>
25 #include <memory>
26 #include <utility>
27 #include <vector>
28 
29 #include "absl/strings/string_view.h"
30 
32 
35 #include "src/core/lib/json/json.h"
39 
40 namespace grpc_core {
41 
42 // Channel arg key for enabling parsing RBAC via method config.
43 #define GRPC_ARG_PARSE_RBAC_METHOD_CONFIG \
44  "grpc.internal.parse_rbac_method_config"
45 
47  public:
48  explicit RbacMethodParsedConfig(std::vector<Rbac> rbac_policies) {
49  for (auto& rbac_policy : rbac_policies) {
50  authorization_engines_.emplace_back(std::move(rbac_policy));
51  }
52  }
53 
54  // Returns the authorization engine for a rbac policy at a certain index. For
55  // a connection on the server, multiple RBAC policies might be active. The
56  // RBAC filter uses this method to get the RBAC policy configured for a
57  // instance at a particular instance.
59  if (index >= authorization_engines_.size()) {
60  return nullptr;
61  }
63  }
64 
65  private:
66  std::vector<GrpcAuthorizationEngine> authorization_engines_;
67 };
68 
70  public:
71  absl::string_view name() const override { return parser_name(); }
72  // Parses the per-method service config for rbac filter.
73  std::unique_ptr<ServiceConfigParser::ParsedConfig> ParsePerMethodParams(
74  const grpc_channel_args* args, const Json& json,
75  grpc_error_handle* error) override;
76  // Returns the parser index for RbacServiceConfigParser.
77  static size_t ParserIndex();
78  // Registers RbacServiceConfigParser to ServiceConfigParser.
80 
81  private:
82  static absl::string_view parser_name() { return "rbac"; }
83 };
84 
85 } // namespace grpc_core
86 
87 #endif // GRPC_CORE_EXT_FILTERS_RBAC_RBAC_SERVICE_CONFIG_PARSER_H
core_configuration.h
grpc_core::RbacServiceConfigParser::ParserIndex
static size_t ParserIndex()
Definition: rbac_service_config_parser.cc:612
grpc_core::RbacMethodParsedConfig::RbacMethodParsedConfig
RbacMethodParsedConfig(std::vector< Rbac > rbac_policies)
Definition: rbac_service_config_parser.h:48
grpc_core
Definition: call_metric_recorder.h:31
grpc_core::CoreConfiguration::Builder
Definition: core_configuration.h:41
grpc_core::ServiceConfigParser::Parser
This is the base class that all service config parsers should derive from.
Definition: lib/service_config/service_config_parser.h:51
grpc_core::RbacMethodParsedConfig::authorization_engines_
std::vector< GrpcAuthorizationEngine > authorization_engines_
Definition: rbac_service_config_parser.h:66
absl::string_view
Definition: abseil-cpp/absl/strings/string_view.h:167
error
grpc_error_handle error
Definition: retry_filter.cc:499
grpc_core::RbacMethodParsedConfig
Definition: rbac_service_config_parser.h:46
grpc_core::RbacServiceConfigParser::ParsePerMethodParams
std::unique_ptr< ServiceConfigParser::ParsedConfig > ParsePerMethodParams(const grpc_channel_args *args, const Json &json, grpc_error_handle *error) override
Definition: rbac_service_config_parser.cc:584
grpc_channel_args
Definition: grpc_types.h:132
grpc_core::GrpcAuthorizationEngine
Definition: grpc_authorization_engine.h:39
grpc_types.h
profile_analyzer.builder
builder
Definition: profile_analyzer.py:159
asyncio_get_stats.args
args
Definition: asyncio_get_stats.py:40
absl::move
constexpr absl::remove_reference_t< T > && move(T &&t) noexcept
Definition: abseil-cpp/absl/utility/utility.h:221
grpc_core::RbacServiceConfigParser::Register
static void Register(CoreConfiguration::Builder *builder)
Definition: rbac_service_config_parser.cc:607
Json
JSON (JavaScript Object Notation).
Definition: third_party/bloaty/third_party/protobuf/conformance/third_party/jsoncpp/json.h:227
rbac_policy.h
error.h
json.h
service_config_parser.h
grpc_core::RbacServiceConfigParser
Definition: rbac_service_config_parser.h:69
grpc_core::RbacServiceConfigParser::name
absl::string_view name() const override
Definition: rbac_service_config_parser.h:71
grpc_authorization_engine.h
index
int index
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/protobuf.h:1184
grpc_core::RbacMethodParsedConfig::authorization_engine
const GrpcAuthorizationEngine * authorization_engine(size_t index) const
Definition: rbac_service_config_parser.h:58
grpc_error
Definition: error_internal.h:42
grpc_core::RbacServiceConfigParser::parser_name
static absl::string_view parser_name()
Definition: rbac_service_config_parser.h:82
grpc_core::ServiceConfigParser::ParsedConfig
Definition: lib/service_config/service_config_parser.h:45
port_platform.h


grpc
Author(s):
autogenerated on Fri May 16 2025 02:59:59