envoyproxy / envoyproxy/envoy

oauth2: configurable safety margin to expire cookies before the contained tokens expire

Open
#45,749 2 comments 0 reactions 0 assignees View on GitHub
area/oauth enhancement help wanted
Dominant language
C++
Stars
28.9k
Forks
5.6k
Avg merge
1d 20h
Merged PRs (30d)
437

Description

*Title*: oauth2: configurable safety margin to expire cookies before the contained tokens expire

*Description*:

Add a configurable safety margin to the OAuth2 HTTP filter so that the browser cookies it sets expire slightly earlier than the tokens they carry. This is the mirror of the `jwt_authn` filter's `clock_skew_seconds`. It shortens cookie validity so a request never arrives at the upstream.

This will prevent errors when the request processing takes seconds or a minute, and the upstream service invokes other services on behalf of the browser user, using the JWT injected by the OAuth2 filter. Using `clock_skew_seconds` does not help because the initial request gets accepted by the OAuth2 filter

A proposal:

```
http_filters:
- name: envoy.filters.http.oauth2
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.http.oauth2.v3.OAuth2
config:
# ...
# Expire/treat the auth cookies as invalid this many seconds before the
# contained token actually expires. Forces re-auth/refresh proactively.
cookie_expiry_margin: 30s # name TBD
```

Contributor guide

Open the contributing guide

Research direction

Start at Envoy's OAuth2 HTTP filter and its OAuth2 v3 configuration, then trace how browser-cookie expiration is derived from the contained token's expiry. Compare the requested behavior with the jwt_authn filter's clock_skew_seconds. Done means the safety margin is configurable and cookies expire early enough to force re-authentication or refresh before an upstream request can use an expired token.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
authentication
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.