Skip to content

fix: add validation for duplicated API keys #5955

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

Merged
merged 1 commit into from
May 9, 2025
Merged

Conversation

gavinkflam
Copy link
Contributor

@gavinkflam gavinkflam commented May 8, 2025

What type of PR is this?

Bug fix

What this PR does / why we need it:

Duplicate API keys in apiKeyAuth can cause the entire controller to stall.

The proposed changes address this by rejecting the affected SecurityPolicy and reporting the error through a status message.

Which issue(s) this PR fixes:

Fixes #5729

Release Notes: Yes

@gavinkflam gavinkflam requested a review from a team as a code owner May 8, 2025 04:36
Copy link

codecov bot commented May 8, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 65.89%. Comparing base (9b78828) to head (9471f8c).
Report is 6 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5955      +/-   ##
==========================================
+ Coverage   65.80%   65.89%   +0.08%     
==========================================
  Files         217      217              
  Lines       36020    36027       +7     
==========================================
+ Hits        23703    23740      +37     
+ Misses      10836    10808      -28     
+ Partials     1481     1479       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@gavinkflam gavinkflam requested a review from arkodg May 8, 2025 17:53
arkodg
arkodg previously approved these changes May 8, 2025
@arkodg arkodg added this to the v1.4.0 milestone May 8, 2025
@arkodg arkodg requested review from a team May 8, 2025 23:03
* reject duplicated API keys
* enhance api-key-auth e2e test to cover duplicated client IDs

Signed-off-by: Gavin Lam <[email protected]>
Comment on lines +13 to +21
apiVersion: v1
kind: Secret
metadata:
namespace: gateway-conformance-infra
name: api-key-auth-users-secret-2
data:
# key2 - duplicate client id should be ignored
client1: "a2V5Mg=="
---
Copy link
Contributor Author

@gavinkflam gavinkflam May 9, 2025

Choose a reason for hiding this comment

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

Enhanced APIKeyAuth e2e test to cover duplicate client IDs. Only the first API key should be retained. For instance, in {client1: "key1"} + {client1: "key2"}, key2 is dropped.

This behavior is documented in the APIKeyAuth documentation.

@arkodg arkodg merged commit 0752df1 into envoyproxy:main May 9, 2025
24 of 25 checks passed
melsal13 referenced this pull request in melsal13/gatewayPersonal May 9, 2025
* reject duplicated API keys
* enhance api-key-auth e2e test to cover duplicated client IDs

Signed-off-by: Gavin Lam <[email protected]>
Signed-off-by: melsal13 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Listener config rejected is shown as warning instead of error
3 participants