-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Rate Limit Configuration: Header value match action #526
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 7 commits
c66f9aa
d892606
122207f
7b31174
9c2432f
b7e6cb4
0612fa5
d9ea002
a06a1f6
8aed769
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -526,14 +526,7 @@ const std::string Json::Schema::ROUTE_ENTRY_CONFIGURATION_SCHEMA(R"EOF( | |
| "type" : "array", | ||
| "minItems" : 1, | ||
| "items" : { | ||
| "type" : "object", | ||
| "properties" : { | ||
| "name" : {"type" : "string"}, | ||
| "value" : {"type" : "string"}, | ||
| "regex" : {"type" : "boolean"} | ||
| }, | ||
| "required" : ["name"], | ||
| "additionalProperties" : false | ||
| "type" : "object" | ||
| } | ||
| }, | ||
| "rate_limits" : {"type" : "array"}, | ||
|
|
@@ -550,6 +543,20 @@ const std::string Json::Schema::ROUTE_ENTRY_CONFIGURATION_SCHEMA(R"EOF( | |
| } | ||
| )EOF"); | ||
|
|
||
| const std::string Json::Schema::HEADER_DATA_CONFIGURATION_SCHEMA(R"EOF( | ||
| { | ||
| "$schema" : "http://json-schema.org/schema#", | ||
| "type" : "object", | ||
| "properties" : { | ||
| "name" : {"type" : "string"}, | ||
| "value" : {"type" : "string"}, | ||
| "regex" : {"type" : "boolean"} | ||
| }, | ||
| "required" : ["name"], | ||
| "additionalProperties" : false | ||
| } | ||
| )EOF"); | ||
|
|
||
| const std::string Json::Schema::HTTP_RATE_LIMITS_CONFIGURATION_SCHEMA(R"EOF( | ||
| { | ||
| "$schema": "http://json-schema.org/schema#", | ||
|
|
@@ -611,6 +618,25 @@ const std::string Json::Schema::HTTP_RATE_LIMITS_CONFIGURATION_SCHEMA(R"EOF( | |
| }, | ||
| "required" : ["type", "descriptor_value"], | ||
| "additionalProperties" : false | ||
| }, | ||
| "header_value_match" : { | ||
| "type" : "object", | ||
| "properties" : { | ||
| "type" : { | ||
| "type" : "string", | ||
| "enum" : ["header_value_match"] | ||
| }, | ||
| "descriptor_value" : {"type" : "string"}, | ||
| "headers" : { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is also duplicated several times now. Can we de-dup and do a sub-schema check in the ConfigUtility code? |
||
| "type" : "array", | ||
| "minItems" : 1, | ||
| "items" : { | ||
| "type" : "object" | ||
| } | ||
| }, | ||
| "required" : ["type", "descriptor_value", "headers"], | ||
| "additionalProperties" : false | ||
| } | ||
| } | ||
| }, | ||
| "type" : "object", | ||
|
|
@@ -626,7 +652,8 @@ const std::string Json::Schema::HTTP_RATE_LIMITS_CONFIGURATION_SCHEMA(R"EOF( | |
| {"$ref" : "#/definitions/destination_cluster"}, | ||
| {"$ref" : "#/definitions/request_headers"}, | ||
| {"$ref" : "#/definitions/remote_address"}, | ||
| {"$ref" : "#/definitions/generic_key"} | ||
| {"$ref" : "#/definitions/generic_key"}, | ||
| {"$ref" : "#/definitions/header_value_match"} | ||
| ] | ||
| } | ||
| } | ||
|
|
@@ -697,14 +724,7 @@ const std::string Json::Schema::FAULT_HTTP_FILTER_SCHEMA(R"EOF( | |
| "type" : "array", | ||
| "minItems" : 1, | ||
| "items" : { | ||
| "type" : "object", | ||
| "properties" : { | ||
| "name" : {"type" : "string"}, | ||
| "value" : {"type" : "string"}, | ||
| "regex" : {"type" : "boolean"} | ||
| }, | ||
| "required" : ["name"], | ||
| "additionalProperties" : false | ||
| "type" : "object" | ||
| } | ||
| } | ||
| }, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| #pragma once | ||
|
|
||
| #include "envoy/json/json_object.h" | ||
|
|
||
| namespace Json { | ||
|
|
||
| class JsonValidator { | ||
| public: | ||
| /* | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: move this comment to class level, you are also missing a '*' in the comment opening. |
||
| * Base class to inherit from to validate config schema before initializing member variables. | ||
| */ | ||
| JsonValidator(const Json::Object& config, const std::string& schema) { | ||
| config.validateSchema(schema); | ||
| } | ||
| }; | ||
|
|
||
| } // Json | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: newline before this line