We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
You can continue the conversation there. Go to discussion →
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is it possible to use WithLeeway with request.ParseFromRequest as with jwt.ParseWithClaims? -> https://github.com/golang-jwt/jwt/blob/v5.0.0/request/request.go
func WithLeeway(leeway time.Duration) ParserOption { return func(p *Parser) { p.validator.leeway = leeway } }
func WithClaims(claims jwt.Claims) ParseFromRequestOption { return func(p *fromRequestParser) { p.claims = claims } }
The text was updated successfully, but these errors were encountered:
You should be able to first create a new parser with jwt.New and jwt.WithLeeway and then use that with request.WithParser
jwt.New
jwt.WithLeeway
request.WithParser
Sorry, something went wrong.
@oxisto, that you! Is the following snippet correct?
func VerifyJWToken(r *http.Request, secretKey []byte) (*jwt.RegisteredClaims, error) { token, err := request.ParseFromRequest(r, request.AuthorizationHeaderExtractor, func(token *jwt.Token) (interface{}, error) { return secretKey, nil }, request.WithClaims(jwt.RegisteredClaims{}), request.WithParser(jwt.NewParser(jwt.WithLeeway(5 * time.Second)))) if err == nil { if claims, ok := token.Claims.(*jwt.RegisteredClaims); ok && token.Valid { return claims, nil } } return nil, err }
No branches or pull requests
Is it possible to use WithLeeway with request.ParseFromRequest as with jwt.ParseWithClaims?
-> https://github.com/golang-jwt/jwt/blob/v5.0.0/request/request.go
The text was updated successfully, but these errors were encountered: