forked from Mirrors/oauth2
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 <bradfitz@golang.org>
This commit is contained in:
parent
e585185218
commit
00dc70155e
2
token.go
2
token.go
|
@ -123,7 +123,7 @@ func (t *Token) expired() bool {
|
||||||
if t.Expiry.IsZero() {
|
if t.Expiry.IsZero() {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return t.Expiry.Add(-expiryDelta).Before(time.Now())
|
return t.Expiry.Round(0).Add(-expiryDelta).Before(time.Now())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Valid reports whether t is non-nil, has an AccessToken, and is not expired.
|
// Valid reports whether t is non-nil, has an AccessToken, and is not expired.
|
||||||
|
|
Loading…
Reference in New Issue