Closed rof20004 closed 4 years ago
Hi all,
I am using chi for tests purposes, but I did not found any example that validates a jwt.MapClaims with expiration time.
I am using this:
var TokenAuth = jwtauth.New(JWTAlgorithm, JWTSecret, nil) // Transaction paths r.Group(func(r chi.Router) { r.Use(jwtauth.Verifier(TokenAuth)) r.Use(jwtauth.Authenticator) _transactionHttpHandler.NewTransactionHandler(r, transactionUsecase) })
And generate JWT with this:
func generateJWT(c *model.Client) (token string, err error) { _, token, err = TokenAuth.Encode(jwt.MapClaims{"clientId": c.ID.String()}) if err != nil { return "", err } return token, nil }
But my token has no expires time and I do not know to do this with this package. Someone can help?
Thanks :)
To anyone wondering:
claims := jwt.MapClaims { "email": "example@example.com, } jwtauth.SetExpiry(claims, time.Now().Add(time.Minute * 5)) _, tokenString, _ := s.App.Jwt().Encode(claims)
Hi all,
I am using chi for tests purposes, but I did not found any example that validates a jwt.MapClaims with expiration time.
I am using this:
And generate JWT with this:
But my token has no expires time and I do not know to do this with this package. Someone can help?
Thanks :)