pomerium/internal/identity
backport-actions-token[bot] 51456671cf
identity: preserve session refresh schedule (#4637)
identity: preserve session refresh schedule (#4633)

The databroker identity manager is responsible for refreshing session
records, to account for overall session expiration as well as OAuth2
access token expiration.

Refresh events are scheduled subject to a coolOffDuration (10 seconds,
by default) relative to a lastRefresh timestamp. Currently, any update
to a session record will reset the associated lastRefresh value and
reschedule any pending refresh event for that session. If an update
occurs close before a scheduled refresh event, this will push back the
scheduled refresh event to 10 seconds from that time.

This means that if a session is updated frequently enough (e.g. if there
is a steady stream of requests that cause constant updates via the
AccessTracker), the access token may expire before a refresh ever runs.

To avoid this problem, do not update the lastRefresh time upon every
session record update, but only if it hasn't yet been set. Instead,
update the lastRefresh during the refresh attempt itself.

Add unit tests to exercise these changes. There is a now() function as
part of the manager configuration (to allow unit tests to set a fake
time); update the Manager to use this function throughout.

Co-authored-by: Kenneth Jenkins <51246568+kenjenkins@users.noreply.github.com>
2023-10-24 15:41:11 -07:00
..
identity store raw id token so it can be passed to the logout url (#1543) 2020-10-26 10:20:23 -06:00
manager identity: preserve session refresh schedule (#4637) 2023-10-24 15:41:11 -07:00
oauth identity: override TokenSource expiry behavior (#4634) 2023-10-24 09:58:47 -07:00
oidc identity: override TokenSource expiry behavior (#4634) 2023-10-24 09:58:47 -07:00
claims.go chore(deps): bump github.com/golangci/golangci-lint from 1.48.0 to 1.50.0 (#3667) 2022-10-19 09:36:59 -06:00
claims_test.go authorize: implement allowed_idp_claims (#1542) 2020-10-23 14:05:37 -06:00
mock_provider.go core/authenticate: refactor idp sign out (#4589) 2023-09-28 08:52:22 -07:00
providers.go core/authenticate: refactor idp sign out (#4589) 2023-09-28 08:52:22 -07:00