Skip to content

Commit d8fbbdf

Browse files
committed
Verify token expiration time
Looks like tokeninfo endpoint won't do that for us, as I mistakenly thought.
1 parent 462dc5f commit d8fbbdf

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

auth_server/server/google_auth.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,12 +354,15 @@ func (ga *GoogleAuth) getIDTokenInfo(token string) (*GoogleTokenInfo, error) {
354354
if ti.Error != "" || ti.ErrorDescription != "" {
355355
return nil, fmt.Errorf("bad token %q: %s %s", token, ti.Error, ti.ErrorDescription)
356356
}
357+
if ti.ExpiresIn <= 0 {
358+
return nil, errors.New("expired token")
359+
}
357360
me := ga.config.ClientId
358361
if ti.Audience != me {
359362
return nil, fmt.Errorf("token intended for %s, not %s", ti.Audience, me)
360363
}
361364
if ti.Email == "" || !ti.VerifiedEmail {
362-
return nil, fmt.Errorf("no verified email in token")
365+
return nil, errors.New("no verified email in token")
363366
}
364367
err = ga.checkDomain(ti.Email)
365368
if err != nil {

0 commit comments

Comments
 (0)