Skip to content
This repository has been archived by the owner on May 21, 2022. It is now read-only.

Add support for leeway #131

Closed
dgrijalva opened this issue Apr 12, 2016 · 3 comments
Closed

Add support for leeway #131

dgrijalva opened this issue Apr 12, 2016 · 3 comments

Comments

@dgrijalva
Copy link
Owner

It's been requested.

See #86

@dgrijalva dgrijalva mentioned this issue Jun 16, 2016
6 tasks
@dgrijalva
Copy link
Owner Author

The RFC says

Implementers MAY provide for some small leeway, usually no more than a few minutes, to account for clock skew

This suggests to me this is not meant to be a property of the token, but an option to the parser. I think we can solve this in the following way:

  • Add a new struct type ValidationOptions with one property (for now) Leeway int
  • Add ValidationOptions as a property on Parser
  • Modify Valid() on Claims to be Valid(opts ValidationOptions)

This would allow leeway to be supported with only very small compatibility changes. It would also allow for future extensions/options without breaking API compatibility.

@dgrijalva
Copy link
Owner Author

In the meantime, you an solve this problem for yourself using the following:

type MyClaims struct {
  *StandardClaims
  Foo string
}

func (c * MyClaims) VerifyExpiresAt(cmp int64, req bool) bool {
        var leeway = 120 // two minutes
    return c.StandardClaims.VerifyExpiresAt(c.ExpiresAt, cmp - leeway, req)
}

@dgrijalva
Copy link
Owner Author

This ticket replaced by #139

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant