Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions REPO_LAYOUT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Repository layout overview

This is a high level overview of how the repository is laid out to both aid in code investigation,
as well as to clearly specify how extensions are added to the repository. The top level directories
are:

* `.circleci/`:
* `bazel/`:
* `ci/`:
* `configs/`:
* `docs/`:
* `examples/`:
* `include/`:
* `restarter/`:
* `source/`:
* `support/`:
* `test/`:
* `tools/`:

## `include/`

## `source/`

## `test/`

## Extension layout
18 changes: 0 additions & 18 deletions include/envoy/ext_authz/BUILD

This file was deleted.

18 changes: 0 additions & 18 deletions source/common/filter/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,3 @@ envoy_cc_library(
"@envoy_api//envoy/config/filter/network/rate_limit/v2:rate_limit_cc",
],
)

envoy_cc_library(
name = "ext_authz_lib",
srcs = ["ext_authz.cc"],
hdrs = ["ext_authz.h"],
deps = [
"//include/envoy/ext_authz:ext_authz_interface",
"//include/envoy/network:connection_interface",
"//include/envoy/network:filter_interface",
"//include/envoy/runtime:runtime_interface",
"//include/envoy/stats:stats_macros",
"//include/envoy/upstream:cluster_manager_interface",
"//source/common/common:assert_lib",
"//source/common/ext_authz:ext_authz_lib",
"//source/common/tracing:http_tracer_lib",
"@envoy_api//envoy/config/filter/network/ext_authz/v2:ext_authz_cc",
],
)
34 changes: 0 additions & 34 deletions source/common/http/filter/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -151,37 +151,3 @@ envoy_cc_library(
"@envoy_api//envoy/config/filter/http/rate_limit/v2:rate_limit_cc",
],
)

envoy_cc_library(
name = "ext_authz_lib",
srcs = ["ext_authz.cc"],
deps = [
":ext_authz_includes",
"//include/envoy/http:codes_interface",
"//source/common/common:assert_lib",
"//source/common/common:empty_string",
"//source/common/common:enum_to_int",
"//source/common/ext_authz:ext_authz_lib",
"//source/common/http:codes_lib",
"//source/common/router:config_lib",
],
)

envoy_cc_library(
name = "ext_authz_includes",
hdrs = ["ext_authz.h"],
deps = [
"//include/envoy/access_log:access_log_interface",
"//include/envoy/ext_authz:ext_authz_interface",
"//include/envoy/http:filter_interface",
"//include/envoy/local_info:local_info_interface",
"//include/envoy/runtime:runtime_interface",
"//include/envoy/upstream:cluster_manager_interface",
"//source/common/common:assert_lib",
"//source/common/http:header_map_lib",
"//source/common/json:config_schemas_lib",
"//source/common/json:json_loader_lib",
"//source/common/json:json_validator_lib",
"@envoy_api//envoy/config/filter/http/ext_authz/v2:ext_authz_cc",
],
)
2 changes: 0 additions & 2 deletions source/exe/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ envoy_cc_library(
"//source/server/config/access_log:grpc_access_log_lib",
"//source/server/config/http:buffer_lib",
"//source/server/config/http:cors_lib",
"//source/server/config/http:ext_authz_lib",
"//source/server/config/http:fault_lib",
"//source/server/config/http:grpc_http1_bridge_lib",
"//source/server/config/http:grpc_json_transcoder_lib",
Expand All @@ -53,7 +52,6 @@ envoy_cc_library(
"//source/server/config/http:router_lib",
"//source/server/config/listener:original_dst_lib",
"//source/server/config/listener:proxy_protocol_lib",
"//source/server/config/network:ext_authz_lib",
"//source/server/config/network:http_connection_manager_lib",
"//source/server/config/network:ratelimit_lib",
"//source/server/config/network:raw_buffer_socket_lib",
Expand Down
2 changes: 2 additions & 0 deletions source/extensions/all_extensions.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
# selection options such as maturity.
def envoy_all_extensions(repository = ""):
return [
repository + "//source/extensions/filters/http/ext_authz:config",
repository + "//source/extensions/filters/network/client_ssl_auth:config",
repository + "//source/extensions/filters/network/echo:config",
repository + "//source/extensions/filters/network/ext_authz:config",
repository + "//source/extensions/filters/network/mongo_proxy:config",
repository + "//source/extensions/filters/network/tcp_proxy:config",
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,21 @@ load(

envoy_package()

envoy_cc_library(
name = "ext_authz_interface",
hdrs = ["ext_authz.h"],
deps = [
"//include/envoy/tracing:http_tracer_interface",
"@envoy_api//envoy/service/auth/v2:external_auth_cc",
],
)

envoy_cc_library(
name = "ext_authz_lib",
srcs = ["ext_authz_impl.cc"],
hdrs = ["ext_authz_impl.h"],
deps = [
"//include/envoy/ext_authz:ext_authz_interface",
":ext_authz_interface",
"//include/envoy/grpc:async_client_interface",
"//include/envoy/grpc:async_client_manager_interface",
"//include/envoy/http:filter_interface",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
#include "envoy/tracing/http_tracer.h"

namespace Envoy {
namespace Extensions {
namespace Filters {
namespace Common {
namespace ExtAuthz {

/**
Expand Down Expand Up @@ -64,4 +67,7 @@ class Client {
typedef std::unique_ptr<Client> ClientPtr;

} // namespace ExtAuthz
} // namespace Common
} // namespace Filters
} // namespace Extensions
} // namespace Envoy
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "common/ext_authz/ext_authz_impl.h"
#include "extensions/filters/common/ext_authz/ext_authz_impl.h"

#include <chrono>
#include <cstdint>
Expand All @@ -15,9 +15,10 @@
#include "common/network/utility.h"
#include "common/protobuf/protobuf.h"

#include "fmt/format.h"

namespace Envoy {
namespace Extensions {
namespace Filters {
namespace Common {
namespace ExtAuthz {

GrpcClientImpl::GrpcClientImpl(Grpc::AsyncClientPtr&& async_client,
Expand Down Expand Up @@ -191,4 +192,7 @@ void CheckRequestUtils::createTcpCheck(const Network::ReadFilterCallbacks* callb
}

} // namespace ExtAuthz
} // namespace Common
} // namespace Filters
} // namespace Extensions
} // namespace Envoy
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include <string>
#include <vector>

#include "envoy/ext_authz/ext_authz.h"
#include "envoy/grpc/async_client.h"
#include "envoy/grpc/async_client_manager.h"
#include "envoy/http/filter.h"
Expand All @@ -19,7 +18,12 @@

#include "common/singleton/const_singleton.h"

#include "extensions/filters/common/ext_authz/ext_authz.h"

namespace Envoy {
namespace Extensions {
namespace Filters {
namespace Common {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works well for ext_authz, +1. I'm wondering how you think this structure plays out when we have two HTTP filters with common code (rather than a network and an HTTP file sharing some common code)? Do we still use filters/common, or is there filters/http/common?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was planning on doing filters/http/common and I would do Extensions::HttpFilters::Common::.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would find it really helpful if we had it documented somewhere what goes where and why, as part of this series of PRs. Internally we have a requirements on BUILD files they have a top level comment on what goes where but many of our intermediate directories don't have BUILD files (yet). I'm open to BUILD files in the "empty" directories, or FOO.md files, or a REPO_ORGANIZATION file in a top level directory, or comments on each module why they live where they live, whatever works!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to go ahead and add a REPO_ORGANIZATION.md to the top level in this PR. I think that's a great idea.

namespace ExtAuthz {

typedef Grpc::TypedAsyncRequestCallbacks<envoy::service::auth::v2::CheckResponse>
Expand Down Expand Up @@ -109,4 +113,7 @@ class CheckRequestUtils {
};

} // namespace ExtAuthz
} // namespace Common
} // namespace Filters
} // namespace Extensions
} // namespace Envoy
38 changes: 38 additions & 0 deletions source/extensions/filters/http/ext_authz/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
licenses(["notice"]) # Apache 2

load(
"//bazel:envoy_build_system.bzl",
"envoy_cc_library",
"envoy_package",
)

envoy_package()

envoy_cc_library(
name = "ext_authz",
srcs = ["ext_authz.cc"],
hdrs = ["ext_authz.h"],
deps = [
"//include/envoy/http:codes_interface",
"//source/common/common:assert_lib",
"//source/common/common:empty_string",
"//source/common/common:enum_to_int",
"//source/common/http:codes_lib",
"//source/common/router:config_lib",
"//source/extensions/filters/common/ext_authz:ext_authz_lib",
"@envoy_api//envoy/config/filter/http/ext_authz/v2:ext_authz_cc",
],
)

envoy_cc_library(
name = "config",
srcs = ["config.cc"],
hdrs = ["config.h"],
deps = [
":ext_authz",
"//include/envoy/registry",
"//include/envoy/server:filter_config_interface",
"//source/common/config:well_known_names",
"//source/common/protobuf:utility_lib",
],
)
Original file line number Diff line number Diff line change
@@ -1,48 +1,51 @@
#include "server/config/http/ext_authz.h"
#include "extensions/filters/http/ext_authz/config.h"

#include <chrono>
#include <string>

#include "envoy/config/filter/http/ext_authz/v2/ext_authz.pb.validate.h"
#include "envoy/registry/registry.h"

#include "common/ext_authz/ext_authz_impl.h"
#include "common/http/filter/ext_authz.h"
#include "common/protobuf/utility.h"

#include "extensions/filters/common/ext_authz/ext_authz_impl.h"
#include "extensions/filters/http/ext_authz/ext_authz.h"

namespace Envoy {
namespace Server {
namespace Configuration {
namespace Extensions {
namespace HttpFilters {
namespace ExtAuthz {

HttpFilterFactoryCb ExtAuthzFilterConfig::createFilter(
Server::Configuration::HttpFilterFactoryCb ExtAuthzFilterConfig::createFilter(
const envoy::config::filter::http::ext_authz::v2::ExtAuthz& proto_config, const std::string&,
FactoryContext& context) {
auto filter_config = std::make_shared<Http::ExtAuthz::FilterConfig>(
proto_config, context.localInfo(), context.scope(), context.runtime(),
context.clusterManager());
Server::Configuration::FactoryContext& context) {
auto filter_config =
std::make_shared<FilterConfig>(proto_config, context.localInfo(), context.scope(),
context.runtime(), context.clusterManager());
const uint32_t timeout_ms = PROTOBUF_GET_MS_OR_DEFAULT(proto_config.grpc_service(), timeout, 200);

return [ grpc_service = proto_config.grpc_service(), &context, filter_config,
timeout_ms ](Http::FilterChainFactoryCallbacks & callbacks) {
auto async_client_factory =
context.clusterManager().grpcAsyncClientManager().factoryForGrpcService(grpc_service,
context.scope());
auto client = std::make_unique<Envoy::ExtAuthz::GrpcClientImpl>(
auto client = std::make_unique<Filters::Common::ExtAuthz::GrpcClientImpl>(
async_client_factory->create(), std::chrono::milliseconds(timeout_ms));
callbacks.addStreamDecoderFilter(Http::StreamDecoderFilterSharedPtr{
std::make_shared<Http::ExtAuthz::Filter>(filter_config, std::move(client))});
std::make_shared<Filter>(filter_config, std::move(client))});
};
}

HttpFilterFactoryCb ExtAuthzFilterConfig::createFilterFactory(const Json::Object&,
const std::string&, FactoryContext&) {
Server::Configuration::HttpFilterFactoryCb
ExtAuthzFilterConfig::createFilterFactory(const Json::Object&, const std::string&,
Server::Configuration::FactoryContext&) {
NOT_IMPLEMENTED;
}

HttpFilterFactoryCb
Server::Configuration::HttpFilterFactoryCb
ExtAuthzFilterConfig::createFilterFactoryFromProto(const Protobuf::Message& proto_config,
const std::string& stats_prefix,
FactoryContext& context) {
Server::Configuration::FactoryContext& context) {
return createFilter(
MessageUtil::downcastAndValidate<const envoy::config::filter::http::ext_authz::v2::ExtAuthz&>(
proto_config),
Expand All @@ -52,8 +55,11 @@ ExtAuthzFilterConfig::createFilterFactoryFromProto(const Protobuf::Message& prot
/**
* Static registration for the external authorization filter. @see RegisterFactory.
*/
static Registry::RegisterFactory<ExtAuthzFilterConfig, NamedHttpFilterConfigFactory> register_;
static Registry::RegisterFactory<ExtAuthzFilterConfig,
Server::Configuration::NamedHttpFilterConfigFactory>
register_;

} // namespace Configuration
} // namespace Server
} // namespace ExtAuthz
} // namespace HttpFilters
} // namespace Extensions
} // namespace Envoy
44 changes: 44 additions & 0 deletions source/extensions/filters/http/ext_authz/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#pragma once

#include <string>

#include "envoy/config/filter/http/ext_authz/v2/ext_authz.pb.h"
#include "envoy/server/filter_config.h"

#include "common/config/well_known_names.h"

namespace Envoy {
namespace Extensions {
namespace HttpFilters {
namespace ExtAuthz {

/**
* Config registration for the external authorization filter. @see NamedHttpFilterConfigFactory.
*/
class ExtAuthzFilterConfig : public Server::Configuration::NamedHttpFilterConfigFactory {
public:
Server::Configuration::HttpFilterFactoryCb
createFilterFactory(const Json::Object& json_config, const std::string&,
Server::Configuration::FactoryContext& context) override;

Server::Configuration::HttpFilterFactoryCb
createFilterFactoryFromProto(const Protobuf::Message& proto_config,
const std::string& stats_prefix,
Server::Configuration::FactoryContext& context) override;

ProtobufTypes::MessagePtr createEmptyConfigProto() override {
return ProtobufTypes::MessagePtr{new envoy::config::filter::http::ext_authz::v2::ExtAuthz()};
}

std::string name() override { return Config::HttpFilterNames::get().EXT_AUTHORIZATION; }

private:
Server::Configuration::HttpFilterFactoryCb
createFilter(const envoy::config::filter::http::ext_authz::v2::ExtAuthz& proto_config,
const std::string& stats_prefix, Server::Configuration::FactoryContext& context);
};

} // namespace ExtAuthz
} // namespace HttpFilters
} // namespace Extensions
} // namespace Envoy
Loading