Skip to content

Commit 024f8d9

Browse files
qiwzhangistio-merge-robot
authored andcommitted
Move envoy code to src/envoy/http folder (#1140)
Automatic merge from submit-queue. Move envoy code to src/envoy/http folder **What this PR does / why we need it**: This is one of phases of moving proxy code into folder structures defined in https://docs.google.com/document/d/1Z0TiwIjFsh1ljUyKkL7hoP9tAuZLZaN68iBzwtzZToY/edit# In this phase: 1) move src/envoy/auth to src/envoy/http/jwt_auth 2) change namespace from Envoy::Http::Auth to Envoy::Http::JwtAuth 3) move src/envoy/mixer to src/envoy/http/mixer **Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes # **Special notes for your reviewer**: **Release note**: ```release-note None ```
1 parent 4ba2edb commit 024f8d9

42 files changed

Lines changed: 88 additions & 87 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/envoy/BUILD

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ envoy_cc_binary(
2525
repository = "@envoy",
2626
visibility = ["//visibility:public"],
2727
deps = [
28-
"//src/envoy/auth:http_filter_factory",
29-
"//src/envoy/mixer:filter_lib",
28+
"//src/envoy/http/jwt_auth:http_filter_factory",
29+
"//src/envoy/http/mixer:filter_lib",
3030
"@envoy//source/exe:envoy_main_entry_lib",
3131
],
3232
)
File renamed without changes.
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ For every request from user client:
4141
* Start Envoy proxy. Run
4242

4343
```
44-
bazel-bin/src/envoy/envoy -c src/envoy/auth/sample/envoy.conf
44+
bazel-bin/src/envoy/envoy -c src/envoy/http/jwt_auth/sample/envoy.conf
4545
```
4646

4747
* Start backend Echo server.
@@ -53,14 +53,14 @@ go run test/backend/echo/echo.go
5353
* Start (fake) issuer server.
5454

5555
```
56-
go run src/envoy/auth/sample/fake_issuer.go src/envoy/auth/sample/pubkey.jwk
56+
go run src/envoy/http/jwt_auth/sample/fake_issuer.go src/envoy/http/jwt_auth/sample/pubkey.jwk
5757
```
5858

5959
* Then issue HTTP request to proxy.
6060

6161
With valid JWT:
6262
```
63-
token=`cat src/envoy/auth/sample/correct_jwt`
63+
token=`cat src/envoy/http/jwt_auth/sample/correct_jwt`
6464
curl --header "Authorization: Bearer $token" http://localhost:9090/echo -d "hello world"
6565
```
6666
Note: the token is generated by:
@@ -70,7 +70,7 @@ Note: the token is generated by:
7070

7171
With invalid JWT:
7272
```
73-
token=`cat src/envoy/auth/sample/invalid_jwt`
73+
token=`cat src/envoy/http/jwt_auth/sample/invalid_jwt`
7474
curl --header "Authorization: Bearer $token" http://localhost:9090/echo -d "hello world"
7575
```
7676

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,18 @@
1313
* limitations under the License.
1414
*/
1515

16-
#ifndef AUTH_STORE_H
17-
#define AUTH_STORE_H
16+
#ifndef JWT_AUTH_STORE_H
17+
#define JWT_AUTH_STORE_H
1818

1919
#include "common/common/logger.h"
2020
#include "envoy/server/filter_config.h"
2121
#include "envoy/thread_local/thread_local.h"
22-
#include "src/envoy/auth/config.pb.h"
23-
#include "src/envoy/auth/pubkey_cache.h"
22+
#include "src/envoy/http/jwt_auth/config.pb.h"
23+
#include "src/envoy/http/jwt_auth/pubkey_cache.h"
2424

2525
namespace Envoy {
2626
namespace Http {
27-
namespace Auth {
27+
namespace JwtAuth {
2828

2929
// The JWT auth store object to store config and caches.
3030
// It only has pubkey_cache for now. In the future it will have token cache.
@@ -71,8 +71,8 @@ class JwtAuthStoreFactory : public Logger::Loggable<Logger::Id::config> {
7171
ThreadLocal::SlotPtr tls_;
7272
};
7373

74-
} // namespace Auth
74+
} // namespace JwtAuth
7575
} // namespace Http
7676
} // namespace Envoy
7777

78-
#endif // AUTH_STORE_H
78+
#endif // JWT_AUTH_STORE_H
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
syntax = "proto3";
1616

17-
package Envoy.Http.Auth.Config;
17+
package Envoy.Http.JwtAuth.Config;
1818

1919
import "google/protobuf/duration.proto";
2020
import "validate/validate.proto";
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* limitations under the License.
1414
*/
1515

16-
#include "src/envoy/auth/http_filter.h"
16+
#include "src/envoy/http/jwt_auth/http_filter.h"
1717

1818
#include "common/http/message_impl.h"
1919
#include "common/http/utility.h"
@@ -27,7 +27,7 @@ namespace Envoy {
2727
namespace Http {
2828

2929
JwtVerificationFilter::JwtVerificationFilter(Upstream::ClusterManager& cm,
30-
Auth::JwtAuthStore& store)
30+
JwtAuth::JwtAuthStore& store)
3131
: jwt_auth_(cm, store) {}
3232

3333
JwtVerificationFilter::~JwtVerificationFilter() {}
@@ -54,20 +54,20 @@ FilterHeadersStatus JwtVerificationFilter::decodeHeaders(HeaderMap& headers,
5454
return FilterHeadersStatus::StopIteration;
5555
}
5656

57-
void JwtVerificationFilter::onDone(const Auth::Status& status) {
57+
void JwtVerificationFilter::onDone(const JwtAuth::Status& status) {
5858
ENVOY_LOG(debug, "Called JwtVerificationFilter : check complete {}",
5959
int(status));
6060
// This stream has been reset, abort the callback.
6161
if (state_ == Responded) {
6262
return;
6363
}
64-
if (status != Auth::Status::OK) {
64+
if (status != JwtAuth::Status::OK) {
6565
state_ = Responded;
6666
// verification failed
6767
Code code = Code(401); // Unauthorized
6868
// return failure reason as message body
6969
Utility::sendLocalReply(*decoder_callbacks_, false, code,
70-
Auth::StatusToString(status));
70+
JwtAuth::StatusToString(status));
7171
return;
7272
}
7373

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
#pragma once
1717

18-
#include "src/envoy/auth/jwt_authenticator.h"
18+
#include "src/envoy/http/jwt_auth/jwt_authenticator.h"
1919

2020
#include "common/common/logger.h"
2121
#include "server/config/network/http_connection_manager.h"
@@ -25,11 +25,11 @@ namespace Http {
2525

2626
// The Envoy filter to process JWT auth.
2727
class JwtVerificationFilter : public StreamDecoderFilter,
28-
public Auth::JwtAuthenticator::Callbacks,
28+
public JwtAuth::JwtAuthenticator::Callbacks,
2929
public Logger::Loggable<Logger::Id::http> {
3030
public:
3131
JwtVerificationFilter(Upstream::ClusterManager& cm,
32-
Auth::JwtAuthStore& store);
32+
JwtAuth::JwtAuthStore& store);
3333
~JwtVerificationFilter();
3434

3535
// Http::StreamFilterBase
@@ -43,14 +43,14 @@ class JwtVerificationFilter : public StreamDecoderFilter,
4343
StreamDecoderFilterCallbacks& callbacks) override;
4444

4545
private:
46-
// the function for Auth::Authenticator::Callbacks interface.
46+
// the function for JwtAuth::Authenticator::Callbacks interface.
4747
// To be called when its Verify() call is completed.
48-
void onDone(const Auth::Status& status);
48+
void onDone(const JwtAuth::Status& status);
4949

5050
// The callback funcion.
5151
StreamDecoderFilterCallbacks* decoder_callbacks_;
5252
// The auth object.
53-
Auth::JwtAuthenticator jwt_auth_;
53+
JwtAuth::JwtAuthenticator jwt_auth_;
5454

5555
// The state of the request
5656
enum State { Init, Calling, Responded, Complete };

src/envoy/auth/http_filter_factory.cc renamed to src/envoy/http/jwt_auth/http_filter_factory.cc

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
* limitations under the License.
1414
*/
1515

16-
#include "src/envoy/auth/http_filter.h"
16+
#include "src/envoy/http/jwt_auth/http_filter.h"
1717
#include "envoy/registry/registry.h"
1818
#include "google/protobuf/util/json_util.h"
19-
#include "src/envoy/auth/auth_store.h"
20-
#include "src/envoy/auth/config.pb.validate.h"
19+
#include "src/envoy/http/jwt_auth/auth_store.h"
20+
#include "src/envoy/http/jwt_auth/config.pb.validate.h"
2121

2222
namespace Envoy {
2323
namespace Server {
@@ -28,7 +28,7 @@ class JwtVerificationFilterConfig : public NamedHttpFilterConfigFactory {
2828
HttpFilterFactoryCb createFilterFactory(const Json::Object& config,
2929
const std::string&,
3030
FactoryContext& context) override {
31-
Http::Auth::Config::AuthFilterConfig proto_config;
31+
Http::JwtAuth::Config::AuthFilterConfig proto_config;
3232
MessageUtil::loadFromJson(config.asJsonString(), proto_config);
3333
return createFilter(proto_config, context);
3434
}
@@ -38,21 +38,22 @@ class JwtVerificationFilterConfig : public NamedHttpFilterConfigFactory {
3838
FactoryContext& context) override {
3939
return createFilter(
4040
MessageUtil::downcastAndValidate<
41-
const Http::Auth::Config::AuthFilterConfig&>(proto_config),
41+
const Http::JwtAuth::Config::AuthFilterConfig&>(proto_config),
4242
context);
4343
}
4444

4545
ProtobufTypes::MessagePtr createEmptyConfigProto() override {
46-
return ProtobufTypes::MessagePtr{new Http::Auth::Config::AuthFilterConfig};
46+
return ProtobufTypes::MessagePtr{
47+
new Http::JwtAuth::Config::AuthFilterConfig};
4748
}
4849

4950
std::string name() override { return "jwt-auth"; }
5051

5152
private:
5253
HttpFilterFactoryCb createFilter(
53-
const Http::Auth::Config::AuthFilterConfig& proto_config,
54+
const Http::JwtAuth::Config::AuthFilterConfig& proto_config,
5455
FactoryContext& context) {
55-
auto store_factory = std::make_shared<Http::Auth::JwtAuthStoreFactory>(
56+
auto store_factory = std::make_shared<Http::JwtAuth::JwtAuthStoreFactory>(
5657
proto_config, context);
5758
Upstream::ClusterManager& cm = context.clusterManager();
5859
return [&cm, store_factory](
File renamed without changes.

0 commit comments

Comments
 (0)