You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit a885a4d
Browse filesBrowse the repository at this point in the historyBrowse files
fix(golang): finish a device session's refresh in the background after its caller gives up, so a rotated refresh token is kept
The token service rotates the refresh token when it answers a device
session's refresh. A refresh cancelled with its caller after the service
answered dropped the new token, and the next refresh sent one the service
had retired, which it rejects: the strategy could not refresh again without
a new login. This is the failure stack-auth's native refresh now avoids by
finishing the refresh in a task after its caller leaves (#1172); the Go auth
guest runs that refresh inline in WebAssembly, so the Go host has to do the
same.
Strategy.Token now runs its work on a goroutine that holds the strategy's
lock until it is done, and returns to a caller whose context ends at once,
without making a copy of a token nobody will read. The refresh call's
context is marked, and only its requests run under guest.Detach of the
caller's context with a grace of 10 seconds: the refresh finishes, the guest
saves what came back, and the next Token reads it. Past the grace it fails
as a transport failure, well inside the 30-second backstop, so the profile
stays open. Close waits for such a refresh, so its rotated token is saved.
Every other request to the token service, an access-key or OIDC exchange,
rotates nothing and is still cancelled with its caller, as is a ZeroKMS
request, so a cancelled NewClient or a shutdown does not wait on them.
Refs #1169.
0 commit comments