check exp time

This commit is contained in:
Dave Grijalva 2012-04-17 16:52:38 -07:00
parent 7a06ac11be
commit 28479ff357
1 changed files with 6 additions and 1 deletions

7
jwt.go
View File

@ -5,6 +5,7 @@ import (
"errors"
"encoding/base64"
"encoding/json"
"time"
)
// A JWT Token
@ -49,7 +50,11 @@ func Parse(tokenString string, keyFunc func(*Token)(string, error)) (token *Toke
}
// Check expiry times
if exp, ok := token.Claims["exp"].(float64); ok {
if time.Now().Unix() > int64(exp) {
err = errors.New("Token is expired")
}
}
// Lookup key