Merge pull request #6 from cenkalti/master

check nbf claim
This commit is contained in:
Dave Grijalva 2014-02-17 12:53:32 -08:00
commit f80fd39457
1 changed files with 8 additions and 2 deletions

10
jwt.go
View File

@ -117,12 +117,18 @@ func Parse(tokenString string, keyFunc Keyfunc) (token *Token, err error) {
return return
} }
// Check expiry times // Check expiration times
now := TimeFunc().Unix()
if exp, ok := token.Claims["exp"].(float64); ok { if exp, ok := token.Claims["exp"].(float64); ok {
if TimeFunc().Unix() > int64(exp) { if now > int64(exp) {
err = errors.New("Token is expired") err = errors.New("Token is expired")
} }
} }
if nbf, ok := token.Claims["nbf"].(float64); ok {
if now < int64(nbf) {
err = errors.New("Token is not valid yet")
}
}
// Lookup key // Lookup key
var key []byte var key []byte