*: int64 -> float64
diff --git a/jws/claims.go b/jws/claims.go
index a827ccb..068caa8 100644
--- a/jws/claims.go
+++ b/jws/claims.go
@@ -84,19 +84,19 @@
// Expiration retrieves claim "exp" per its type in
// https://tools.ietf.org/html/rfc7519#section-4.1.4
-func (c Claims) Expiration() (int64, bool) {
+func (c Claims) Expiration() (float64, bool) {
return jwt.Claims(c).Expiration()
}
// NotBefore retrieves claim "nbf" per its type in
// https://tools.ietf.org/html/rfc7519#section-4.1.5
-func (c Claims) NotBefore() (int64, bool) {
+func (c Claims) NotBefore() (float64, bool) {
return jwt.Claims(c).NotBefore()
}
// IssuedAt retrieves claim "iat" per its type in
// https://tools.ietf.org/html/rfc7519#section-4.1.6
-func (c Claims) IssuedAt() (int64, bool) {
+func (c Claims) IssuedAt() (float64, bool) {
return jwt.Claims(c).IssuedAt()
}
@@ -161,19 +161,19 @@
// SetExpiration sets claim "exp" per its type in
// https://tools.ietf.org/html/rfc7519#section-4.1.4
-func (c Claims) SetExpiration(expiration int64) {
+func (c Claims) SetExpiration(expiration float64) {
jwt.Claims(c).SetExpiration(expiration)
}
// SetNotBefore sets claim "nbf" per its type in
// https://tools.ietf.org/html/rfc7519#section-4.1.5
-func (c Claims) SetNotBefore(notBefore int64) {
+func (c Claims) SetNotBefore(notBefore float64) {
jwt.Claims(c).SetNotBefore(notBefore)
}
// SetIssuedAt sets claim "iat" per its type in
// https://tools.ietf.org/html/rfc7519#section-4.1.6
-func (c Claims) SetIssuedAt(issuedAt int64) {
+func (c Claims) SetIssuedAt(issuedAt float64) {
jwt.Claims(c).SetIssuedAt(issuedAt)
}
diff --git a/jws/jwt.go b/jws/jwt.go
index c8f7a69..51090b4 100644
--- a/jws/jwt.go
+++ b/jws/jwt.go
@@ -67,7 +67,7 @@
if err := v1.Validate(j); err != nil {
return err
}
- return jwt.Claims(c).Validate(time.Now().Unix(), v1.EXP, v1.NBF)
+ return jwt.Claims(c).Validate(float64(time.Now().Unix()), v1.EXP, v1.NBF)
}
}
return ErrIsNotJWT
@@ -85,7 +85,7 @@
// NewValidator returns a pointer to a jwt.Validator structure containing
// the info to be used in the validation of a JWT.
-func NewValidator(c Claims, exp, nbf int64, fn func(Claims) error) *jwt.Validator {
+func NewValidator(c Claims, exp, nbf float64, fn func(Claims) error) *jwt.Validator {
return &jwt.Validator{
Expected: jwt.Claims(c),
EXP: exp,
diff --git a/jws/jwt_test.go b/jws/jwt_test.go
index 91662a0..a8acb10 100644
--- a/jws/jwt_test.go
+++ b/jws/jwt_test.go
@@ -61,7 +61,7 @@
t.Error(err)
}
- d := time.Now().Add(1 * time.Hour).Unix()
+ d := float64(time.Now().Add(1 * time.Hour).Unix())
fn := func(c Claims) error {
if c.Get("name") != "Eric" &&
c.Get("admin") != true &&
diff --git a/jwt/claims.go b/jwt/claims.go
index 547e4c0..32d499f 100644
--- a/jwt/claims.go
+++ b/jwt/claims.go
@@ -12,7 +12,7 @@
// Validate validates the Claims per the claims found in
// https://tools.ietf.org/html/rfc7519#section-4.1
-func (c Claims) Validate(now, expLeeway, nbfLeeway int64) error {
+func (c Claims) Validate(now, expLeeway, nbfLeeway float64) error {
if exp, ok := c.Expiration(); ok {
if !within(exp, expLeeway, now) {
return ErrTokenIsExpired
@@ -27,7 +27,7 @@
return nil
}
-func within(cur, delta, max int64) bool {
+func within(cur, delta, max float64) bool {
return cur+delta < max || cur-delta < max
}
@@ -142,22 +142,22 @@
// Expiration retrieves claim "exp" per its type in
// https://tools.ietf.org/html/rfc7519#section-4.1.4
-func (c Claims) Expiration() (int64, bool) {
- v, ok := c.Get("exp").(int64)
+func (c Claims) Expiration() (float64, bool) {
+ v, ok := c.Get("exp").(float64)
return v, ok
}
// NotBefore retrieves claim "nbf" per its type in
// https://tools.ietf.org/html/rfc7519#section-4.1.5
-func (c Claims) NotBefore() (int64, bool) {
- v, ok := c.Get("nbf").(int64)
+func (c Claims) NotBefore() (float64, bool) {
+ v, ok := c.Get("nbf").(float64)
return v, ok
}
// IssuedAt retrieves claim "iat" per its type in
// https://tools.ietf.org/html/rfc7519#section-4.1.6
-func (c Claims) IssuedAt() (int64, bool) {
- v, ok := c.Get("iat").(int64)
+func (c Claims) IssuedAt() (float64, bool) {
+ v, ok := c.Get("iat").(float64)
return v, ok
}
@@ -213,19 +213,19 @@
// SetExpiration sets claim "exp" per its type in
// https://tools.ietf.org/html/rfc7519#section-4.1.4
-func (c Claims) SetExpiration(expiration int64) {
+func (c Claims) SetExpiration(expiration float64) {
c.Set("exp", expiration)
}
// SetNotBefore sets claim "nbf" per its type in
// https://tools.ietf.org/html/rfc7519#section-4.1.5
-func (c Claims) SetNotBefore(notBefore int64) {
+func (c Claims) SetNotBefore(notBefore float64) {
c.Set("nbf", notBefore)
}
// SetIssuedAt sets claim "iat" per its type in
// https://tools.ietf.org/html/rfc7519#section-4.1.6
-func (c Claims) SetIssuedAt(issuedAt int64) {
+func (c Claims) SetIssuedAt(issuedAt float64) {
c.Set("iat", issuedAt)
}
diff --git a/jwt/jwt.go b/jwt/jwt.go
index 1c64ef7..dbbf03d 100644
--- a/jwt/jwt.go
+++ b/jwt/jwt.go
@@ -38,8 +38,8 @@
// Validator represents some of the validation options.
type Validator struct {
Expected Claims // If non-nil, these are required to match.
- EXP int64 // EXPLeeway
- NBF int64 // NBFLeeway
+ EXP float64 // EXPLeeway
+ NBF float64 // NBFLeeway
Fn ValidateFunc // See ValidateFunc for more information.
_ struct{}
@@ -114,21 +114,21 @@
// SetExpiration sets the "exp" claim per
// https://tools.ietf.org/html/rfc7519#section-4.1.4
-func (v *Validator) SetExpiration(exp int64) {
+func (v *Validator) SetExpiration(exp float64) {
v.expect()
v.Expected.Set("exp", exp)
}
// SetNotBefore sets the "nbf" claim per
// https://tools.ietf.org/html/rfc7519#section-4.1.5
-func (v *Validator) SetNotBefore(nbf int64) {
+func (v *Validator) SetNotBefore(nbf float64) {
v.expect()
v.Expected.Set("nbf", nbf)
}
// SetIssuedAt sets the "iat" claim per
// https://tools.ietf.org/html/rfc7519#section-4.1.6
-func (v *Validator) SetIssuedAt(iat int64) {
+func (v *Validator) SetIssuedAt(iat float64) {
v.expect()
v.Expected.Set("iat", iat)
}