pomerium/internal/identity/oidc
backport-actions-token[bot] 35ef3274de
identity: override TokenSource expiry behavior (#4634)
identity: override TokenSource expiry behavior (#4632)

The current session refresh loop attempts to refresh access tokens when
they are due to expire in less than one minute. However, the code to
perform the refresh relies on a TokenSource from the x/oauth2 package,
which has its own internal 'expiryDelta' threshold, with a default of
10 seconds. As a result, the first four or five attempts to refresh a
particular access token will not actually refresh the token. The refresh
will happen only when the access token is within 10 seconds of expiring.

Instead, before we obtain a new TokenSource, first clear any existing
access token. This causes the TokenSource to consider the token invalid,
triggering a refresh. This should give the refresh loop more control
over when refreshes happen.

Consolidate this logic in a new Refresh() method in the oidc package.
Add unit tests for this new method.

Co-authored-by: Kenneth Jenkins <51246568+kenjenkins@users.noreply.github.com>
2023-10-24 09:58:47 -07:00
..
auth0 core/authenticate: refactor idp sign out (#4589) 2023-09-28 08:52:22 -07:00
azure Allow clearing default Azure and Google auth code options (#4315) 2023-06-27 09:11:54 -07:00
cognito core/authenticate: refactor idp sign out (#4589) 2023-09-28 08:52:22 -07:00
gitlab docs: update references, remove docs dir (#3420) 2022-06-13 16:52:52 -07:00
google Allow clearing default Azure and Google auth code options (#4315) 2023-06-27 09:11:54 -07:00
okta docs: update references, remove docs dir (#3420) 2022-06-13 16:52:52 -07:00
onelogin docs: update references, remove docs dir (#3420) 2022-06-13 16:52:52 -07:00
ping docs: update references, remove docs dir (#3420) 2022-06-13 16:52:52 -07:00
config.go authenticate: delay evaluation of OIDC provider (#1802) 2021-01-26 09:20:56 -07:00
errors.go authenticate: save oauth2 tokens to cache (#698) 2020-05-18 17:10:10 -04:00
oidc.go identity: override TokenSource expiry behavior (#4634) 2023-10-24 09:58:47 -07:00
oidc_test.go oidc: fix token revocation (#3810) 2022-12-16 13:24:40 -07:00
refresh.go identity: override TokenSource expiry behavior (#4634) 2023-10-24 09:58:47 -07:00
refresh_test.go identity: override TokenSource expiry behavior (#4634) 2023-10-24 09:58:47 -07:00
userinfo.go remove deprecated ioutil usages (#2877) 2021-12-30 10:02:12 -08:00
userinfo_test.go identity: infer email from mail claim (#1977) 2021-03-12 09:01:21 -07:00