-
Notifications
You must be signed in to change notification settings - Fork 234
feat: rate limit config per key [WIP] #2089
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 all commits
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 | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1820,6 +1820,47 @@ | |||||||||||||||||||||||
| "type": "boolean", | ||||||||||||||||||||||||
| "default": false, | ||||||||||||||||||||||||
| "description": "Hide the rate limit stats from the response extension. If the value is true, the rate limit stats are not included in the response extension." | ||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||
| "key_mapping": { | ||||||||||||||||||||||||
| "type": "object", | ||||||||||||||||||||||||
| "description": "The configuration per key entry.", | ||||||||||||||||||||||||
| "additionalProperties": { | ||||||||||||||||||||||||
|
Comment on lines
+1823
to
+1827
Contributor
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. 🛠️ Refactor suggestion Add basic constraints to
"key_mapping": {
"type": "object",
"description": "The configuration per key entry.",
+ "minProperties": 1,
"additionalProperties": {📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||
| "type": "object", | ||||||||||||||||||||||||
| "additionalProperties": false, | ||||||||||||||||||||||||
| "description": "The configuration for all subgraphs. The configuration is used to configure the traffic shaping for all subgraphs.", | ||||||||||||||||||||||||
| "properties": { | ||||||||||||||||||||||||
| "enabled": { | ||||||||||||||||||||||||
| "type": "boolean", | ||||||||||||||||||||||||
| "description": "The rate at which the requests are allowed. The rate is specified as a number of requests per second." | ||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||
| "rate": { | ||||||||||||||||||||||||
| "type": "integer", | ||||||||||||||||||||||||
| "description": "The rate at which the requests are allowed. The rate is specified as a number of requests per second.", | ||||||||||||||||||||||||
| "minimum": 1 | ||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||
| "burst": { | ||||||||||||||||||||||||
| "type": "integer", | ||||||||||||||||||||||||
| "description": "The maximum number of requests that are allowed to exceed the rate. The burst is specified as a number of requests.", | ||||||||||||||||||||||||
| "minimum": 1 | ||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||
| "period": { | ||||||||||||||||||||||||
| "type": "string", | ||||||||||||||||||||||||
| "description": "The period of time over which the rate limit is enforced. The period is specified as a string with a number and a unit, e.g. 10ms, 1s, 1m, 1h. The supported units are 'ms', 's', 'm', 'h'.", | ||||||||||||||||||||||||
| "duration": { | ||||||||||||||||||||||||
| "minimum": "1s" | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||
| "reject_exceeding_requests": { | ||||||||||||||||||||||||
| "type": "boolean", | ||||||||||||||||||||||||
| "description": "Reject the requests that exceed the rate limit. If the value is true, the requests that exceed the rate limit are rejected." | ||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||
| "reject_status_code": { | ||||||||||||||||||||||||
| "type": "integer", | ||||||||||||||||||||||||
| "description": "The status code to return when the request is rejected. The default value is 200 (OK) as we're returning a well formed GraphQL response.", | ||||||||||||||||||||||||
| "default": 200 | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
Comment on lines
+1836
to
+1862
Contributor
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. Require at least one rate-limiting parameter inside each mapping entry All properties inside a single entry are optional, so a definition like: rate_limit:
simple_strategy:
key_mapping:
employees: {}would pass schema validation yet leave the router with undefined values at runtime. "additionalProperties": false,
...
-"description": "The configuration for all subgraphs. The configuration is used to configure the traffic shaping for all subgraphs.",
+"description": "Per-key rate-limit settings. At least one of rate | burst | period must be supplied.",
...
- "properties": {
+ "properties": {
...
},
+ "anyOf": [
+ { "required": ["rate"] },
+ { "required": ["burst"] },
+ { "required": ["period"] }
+ ]Alternatively, replicate the global 🤖 Prompt for AI Agents |
||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||
| "required": ["rate", "burst", "period"] | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
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.
💡 Verification agent
🧩 Analysis chain
Verify the dramatic increase in JWKS refresh frequency.
The refresh rate for unknown Key IDs has been increased from once every 5 minutes to once every 2 seconds - a 150x increase in frequency. This could significantly impact performance and potentially overwhelm JWKS providers with requests.
Please verify this change is intentional and consider the following:
🏁 Script executed:
Length of output: 1639
Document and validate JWKS unknown‐KID refresh rate change
The hard-coded
RefreshUnknownKIDlimiter was lowered from 5 minutes to 2 seconds (150× increase), but there’s no accompanying comment or configuration entry explaining why. This could lead to a surge of HTTP requests against JWKS endpoints.Please address the following in
router/pkg/authentication/jwks_token_decoder.go:99:authentication.JWKSConfig) with a clear rationale.🤖 Prompt for AI Agents