go-chi / jwtauth

JWT authentication middleware for Go HTTP services
MIT License
541 stars 91 forks source link

How to use JWT expiration? #76

Closed Thecrafterja closed 1 year ago

Thecrafterja commented 1 year ago

Hey, I just started using this awesome libary and I have a "basic" question.

I want to have jwt tokens with an expiration date. My first thought was to handle this through a second claim. Then I had a look at jwtauth.go and saw, that there is a possible error regarding to the expiration date. But I did not find an option to set the expiration date for a jwt token generated with TokenAuth.Encode() function.

I would be glad to get a reply.

Thanks, Thecrafterja

Thecrafterja commented 1 year ago

Hey, I was just too unexperienced with jwts.

If anyone has the same question: You need to define "exp" as an jwt argument thorugh the Encode() function.