oauth2: add cookie expiration margin#45810
Conversation
|
Hi @ftaboadac, welcome and thank you for your contribution. We will try to review your Pull Request as quickly as possible. In the meantime, please take a look at the contribution guidelines if you have not done so already. |
|
CC @envoyproxy/api-shepherds: Your approval is needed for changes made to |
| std::chrono::seconds(600)); | ||
| } | ||
|
|
||
| TEST_F(OAuth2Test, OAuthAccessTokenSucessWithCookieExpirationMarginEqualToTokenLifetime) { |
There was a problem hiding this comment.
I would explicitly test the overflow case as well.
There was a problem hiding this comment.
Done, added an explicit cookie_expiration_margin > token lifetime test case
Signed-off-by: Facundo Taboada <ftaboadacuria@gmail.com>
93b3ce7 to
495e3f6
Compare
Signed-off-by: Facundo Taboada <ftaboadacuria@gmail.com>
|
@mattklein123 Thanks for the review. It looks like CI is still blocked on external contributor approval. Could someone approve the workflow run when available? |
Signed-off-by: Facundo Taboada <ftaboadacuria@gmail.com>
|
Pushed a follow-up fix for the CI failure. The issue was a proto field number conflict after merging |
Commit Message:
oauth2: add cookie expiration margin
Additional Description:
Adds
cookie_expiration_marginto the OAuth2 HTTP filter. When configured, the filter subtracts this margin from the lifetime of OAuth2 auth-related cookies whose expiration is derived from token/session expiry, including the bearer token, ID token, refresh token, OAuth expiry, and HMAC cookies.This lets Envoy proactively refresh or re-authenticate before forwarding a request with a token that is close to expiration, matching the motivation in #45749.
The default is unchanged when
cookie_expiration_marginis unset or zero.This PR was prepared with assistance from OpenAI Codex. I reviewed and understand the submitted code and tests, and take responsibility for the change.
Risk Level:
Low. The new field is optional and the default behavior is unchanged.
Testing:
Added OAuth2 filter unit coverage for:
Max-Agevalues to 0 rather than underflowingAlso ran:
git diff --checkDocs Changes:
Added inline API documentation for
cookie_expiration_marginand updated the OAuth2 filter documentation with a short description and example configuration.Release Notes:
Added changelog fragment under
changelogs/current/new_features.Platform Specific Features:
N/A
[Optional Runtime guard:]
N/A
[Optional Fixes #Issue]
Fixes #45749
[Optional Fixes commit #PR or SHA]
N/A
[Optional Deprecated:]
N/A
[Optional API Considerations:]
Adds a new optional field to the existing v3 OAuth2 filter config. The default is unset/0, preserving existing behavior.