Skip to content

Commit 0dc4d20

Browse files
oauth2: make CSRF and code verifier token expiration configurable (#39877)
Commit Message: oauth2: make CSRF and code verifier token expiration configurable Additional Description: Currently, the OAuth2 filter hardcodes the values of the CSRF and code verifier tokens to `600s` (10 minutes) . This limits flexibility for use cases where: - Users need shorter expiration (e.g., high-security scenarios). - Users need longer expiration (e.g., backward-compatibility). This PR makes both tokens configurable, adding `default_csrf_token_expires_in` and `default_code_verifier_token_expires_in` fields to the OAuth2 filter configuration. Both default to ``600s`` (10 minutes) if not specified, keeping backward compatibility. Risk Level: Low Testing: Added tests for cases where uses sets the values of the new fields in the configuration. The default values are already tested in almost all the tests. Docs Changes: N/A Release Notes: N/A Platform Specific Features: N/A [Optional Runtime guard:] [Optional Fixes #Issue] [Optional Fixes commit #PR or SHA] [Optional Deprecated:] [Optional [API Considerations](https://github.com/envoyproxy/envoy/blob/main/api/review_checklist.md):] --------- Signed-off-by: Gustavo Moyano <[email protected]> Mirrored from https://github.com/envoyproxy/envoy @ d7a588d5ccdfd9bcccad57dd9b764683017e0da1
1 parent 43ea4e3 commit 0dc4d20

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

envoy/extensions/filters/http/oauth2/v3/oauth.proto

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ message OAuth2Credentials {
126126

127127
// OAuth config
128128
//
129-
// [#next-free-field: 24]
129+
// [#next-free-field: 26]
130130
message OAuth2Config {
131131
enum AuthType {
132132
// The ``client_id`` and ``client_secret`` will be sent in the URL encoded request body.
@@ -242,6 +242,18 @@ message OAuth2Config {
242242

243243
// Optional additional prefix to use when emitting statistics.
244244
string stat_prefix = 22;
245+
246+
// Optional expiration time for the CSRF protection token cookie.
247+
// The CSRF token prevents cross-site request forgery attacks during the OAuth2 flow.
248+
// If not specified, defaults to ``600s`` (10 minutes), which should provide sufficient time
249+
// for users to complete the OAuth2 authorization flow.
250+
google.protobuf.Duration csrf_token_expires_in = 24;
251+
252+
// Optional expiration time for the code verifier cookie.
253+
// The code verifier is stored in a secure, HTTP-only cookie during the OAuth2 authorization process.
254+
// If not specified, defaults to ``600s`` (10 minutes), which should provide sufficient time
255+
// for users to complete the OAuth2 authorization flow.
256+
google.protobuf.Duration code_verifier_token_expires_in = 25;
245257
}
246258

247259
// Filter config.

0 commit comments

Comments
 (0)