Skip to content

Commit 00dc701

Browse files
BlakeMesdagbradfitz
authored andcommitted
oauth2: ignore monotonic time when considering whether Tokens are expired
This change ensures time comparisons Token expiry checking uses the wall clock instead of the monotonic clock. This situation can occur on laptops which enter sleep mode and don't advance their monotonic clock. Change-Id: If8518e96ca04f2137db4703440ff3b851d221aae Reviewed-on: https://go-review.googlesource.com/83575 Reviewed-by: Brad Fitzpatrick <[email protected]>
1 parent e585185 commit 00dc701

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

token.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ func (t *Token) expired() bool {
123123
if t.Expiry.IsZero() {
124124
return false
125125
}
126-
return t.Expiry.Add(-expiryDelta).Before(time.Now())
126+
return t.Expiry.Round(0).Add(-expiryDelta).Before(time.Now())
127127
}
128128

129129
// Valid reports whether t is non-nil, has an AccessToken, and is not expired.

0 commit comments

Comments
 (0)