-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
implement api-level request size limit for oas (TT-11459) #6822
base: master
Are you sure you want to change the base?
Conversation
API Changes --- prev.txt 2025-01-09 12:07:54.268971184 +0000
+++ current.txt 2025-01-09 12:07:49.515965936 +0000
@@ -1456,6 +1456,7 @@
GlobalResponseHeadersDisabled bool `bson:"global_response_headers_disabled" json:"global_response_headers_disabled"`
IgnoreEndpointCase bool `bson:"ignore_endpoint_case" json:"ignore_endpoint_case"`
GlobalSizeLimit int64 `bson:"global_size_limit" json:"global_size_limit"`
+ GlobalSizeLimitDisabled bool `bson:"global_size_limit_disabled" json:"global_size_limit_disabled"`
OverrideTarget string `bson:"override_target" json:"override_target"`
}
@@ -2728,6 +2729,9 @@
// TrafficLogs contains the configurations related to API level log analytics.
TrafficLogs *TrafficLogs `bson:"trafficLogs,omitempty" json:"trafficLogs,omitempty"`
+
+ // RequestSizeLimit contains the configuration related to limiting the global request size.
+ RequestSizeLimit *GlobalRequestSizeLimit `bson:"requestSizeLimit,omitempty" json:"requestSizeLimit,omitempty"`
}
Global contains configuration that affects the whole API (all endpoints).
@@ -2744,6 +2748,23 @@
ensures backwards compatibility and proper handling of the deprecated fields
during the migration process.
+type GlobalRequestSizeLimit struct {
+ // Enabled activates the Request Size Limit.
+ // Tyk classic API definition: `version_data.versions..global_size_limit_disabled`.
+ Enabled bool `bson:"enabled" json:"enabled"`
+ // Value contains the value of the request size limit.
+ // Tyk classic API definition: `version_data.versions..global_size_limit`.
+ Value int64 `bson:"value" json:"value"`
+}
+ GlobalRequestSizeLimit holds configuration about the global limits for
+ request sizes.
+
+func (g *GlobalRequestSizeLimit) ExtractTo(api *apidef.APIDefinition)
+ ExtractTo extracts *GlobalRequestSizeLimit into *apidef.APIDefinition.
+
+func (g *GlobalRequestSizeLimit) Fill(api apidef.APIDefinition)
+ Fill fills *GlobalRequestSizeLimit from apidef.APIDefinition.
+
type HMAC struct {
// Enabled activates the HMAC authentication mode.
// Tyk classic API definition: `enable_signature_checking`
@@ -3929,9 +3950,6 @@
// Enabled enables traffic log analytics for the API.
// Tyk classic API definition: `do_not_track`.
Enabled bool `bson:"enabled" json:"enabled"`
- // TagHeaders is a string array of HTTP headers that can be extracted
- // and transformed into analytics tags (statistics aggregated by tag, per hour).
- TagHeaders []string `bson:"tagHeaders" json:"tagHeaders,omitempty"`
}
TrafficLogs holds configuration about API log analytics.
@@ -12495,8 +12513,6 @@
package regression // import "github.com/TykTechnologies/tyk/tests/regression"
-# Package: ./tests/system
-
# Package: ./trace
package trace // import "github.com/TykTechnologies/tyk/trace" |
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
Quality Gate failedFailed conditions |
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.
lgtm
User description
TT-11459
This PR adds support for API-level request size limit for OAS.
Types of changes
PR Type
Enhancement, Tests, Documentation
Description
Implemented API-level request size limit for OAS.
Added
GlobalRequestSizeLimit
struct and related methods.Updated OAS schema and documentation for request size limit.
Added comprehensive tests for request size limit functionality.
Changes walkthrough 📝
api_definitions.go
Add support for request size limit in API definitions
apidef/api_definitions.go
GlobalSizeLimitDisabled
field toVersionInfo
.middleware.go
Add request size limit handling in middleware
apidef/oas/middleware.go
RequestSizeLimit
field inGlobal
struct.mw_request_size_limit.go
Update middleware to respect request size limit
gateway/mw_request_size_limit.go
EnabledForSpec
to checkGlobalSizeLimitDisabled
.x-tyk-api-gateway.json
Update OAS schema for request size limit
apidef/oas/schema/x-tyk-api-gateway.json
X-Tyk-GlobalRequestSizeLimit
definition.requestSizeLimit
field.middleware_test.go
Add tests for request size limit functionality
apidef/oas/middleware_test.go
GlobalRequestSizeLimit
functionality.Fill
andExtractTo
methods.oas_test.go
Update OAS tests for request size limit
apidef/oas/oas_test.go
GlobalSizeLimitDisabled
field.mw_request_size_limit_test.go
Add middleware tests for request size limit
gateway/mw_request_size_limit_test.go
EnabledForSpec
with various configurations.apidef-oas.md
Update documentation for request size limit
docs/dev/apidef-oas.md
VersionData
handling for request size limit.Fill
andExtractTo
methods.