From 00dc70155e4c968f5afa403a799926838a4aa28f Mon Sep 17 00:00:00 2001 From: Blake Mesdag Date: Tue, 12 Dec 2017 15:00:05 -0500 Subject: [PATCH] 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 --- token.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/token.go b/token.go index bdac1de..d8534de 100644 --- a/token.go +++ b/token.go @@ -123,7 +123,7 @@ func (t *Token) expired() bool { if t.Expiry.IsZero() { 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.