Skip to content

Commit

Permalink
Fix bearer token expiration check (fixes #3779)
Browse files Browse the repository at this point in the history
Signed-off-by: Vladislav Ivanov <[email protected]>
(cherry picked from commit fc834f5)
  • Loading branch information
vlad-ivanov-name authored and tonistiigi committed Apr 20, 2023
1 parent 7ddae62 commit c48a6bc
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion util/resolver/authorizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,15 @@ func (ah *authHandler) fetchToken(ctx context.Context, sm *session.Manager, g se
if resp.ExpiresIn == 0 {
resp.ExpiresIn = defaultExpiration
}
issuedAt, expires = time.Unix(resp.IssuedAt, 0), int(resp.ExpiresIn)
expires = int(resp.ExpiresIn)
// We later check issuedAt.isZero, which would return
// false if converted from zero Unix time. Therefore,
// zero time value in response is handled separately
if resp.IssuedAt == 0 {
issuedAt = time.Time{}
} else {
issuedAt = time.Unix(resp.IssuedAt, 0)
}
token = resp.Token
return nil, nil
}
Expand Down

0 comments on commit c48a6bc

Please sign in to comment.