/proc/self/cwd/source/extensions/filters/network/ext_authz/config.cc
Line | Count | Source |
1 | | #include "source/extensions/filters/network/ext_authz/config.h" |
2 | | |
3 | | #include <chrono> |
4 | | #include <string> |
5 | | |
6 | | #include "envoy/config/core/v3/grpc_service.pb.h" |
7 | | #include "envoy/extensions/filters/network/ext_authz/v3/ext_authz.pb.h" |
8 | | #include "envoy/extensions/filters/network/ext_authz/v3/ext_authz.pb.validate.h" |
9 | | #include "envoy/network/connection.h" |
10 | | #include "envoy/registry/registry.h" |
11 | | |
12 | | #include "source/common/config/utility.h" |
13 | | #include "source/common/protobuf/utility.h" |
14 | | #include "source/extensions/filters/common/ext_authz/ext_authz.h" |
15 | | #include "source/extensions/filters/common/ext_authz/ext_authz_grpc_impl.h" |
16 | | #include "source/extensions/filters/network/ext_authz/ext_authz.h" |
17 | | |
18 | | namespace Envoy { |
19 | | namespace Extensions { |
20 | | namespace NetworkFilters { |
21 | | namespace ExtAuthz { |
22 | | |
23 | | Network::FilterFactoryCb ExtAuthzConfigFactory::createFilterFactoryFromProtoTyped( |
24 | | const envoy::extensions::filters::network::ext_authz::v3::ExtAuthz& proto_config, |
25 | 8 | Server::Configuration::FactoryContext& context) { |
26 | 8 | ConfigSharedPtr ext_authz_config = std::make_shared<Config>( |
27 | 8 | proto_config, context.scope(), context.getServerFactoryContext().bootstrap()); |
28 | 8 | const uint32_t timeout_ms = PROTOBUF_GET_MS_OR_DEFAULT(proto_config.grpc_service(), timeout, 200); |
29 | | |
30 | 8 | THROW_IF_NOT_OK(Envoy::Config::Utility::checkTransportVersion(proto_config)); |
31 | 5 | return [grpc_service = proto_config.grpc_service(), &context, ext_authz_config, |
32 | 5 | timeout_ms](Network::FilterManager& filter_manager) -> void { |
33 | 5 | auto async_client_factory = |
34 | 5 | context.clusterManager().grpcAsyncClientManager().factoryForGrpcService( |
35 | 5 | grpc_service, context.scope(), true); |
36 | | |
37 | 5 | auto client = std::make_unique<Filters::Common::ExtAuthz::GrpcClientImpl>( |
38 | 5 | async_client_factory->createUncachedRawAsyncClient(), |
39 | 5 | std::chrono::milliseconds(timeout_ms)); |
40 | 5 | filter_manager.addReadFilter(Network::ReadFilterSharedPtr{ |
41 | 5 | std::make_shared<Filter>(ext_authz_config, std::move(client))}); |
42 | 5 | }; |
43 | 8 | } |
44 | | |
45 | | /** |
46 | | * Static registration for the external authorization filter. @see RegisterFactory. |
47 | | */ |
48 | | LEGACY_REGISTER_FACTORY(ExtAuthzConfigFactory, |
49 | | Server::Configuration::NamedNetworkFilterConfigFactory, "envoy.ext_authz"); |
50 | | |
51 | | } // namespace ExtAuthz |
52 | | } // namespace NetworkFilters |
53 | | } // namespace Extensions |
54 | | } // namespace Envoy |