{"repo":"go-chi/jwtauth","free":true,"listed":false,"github":"https://github.com/go-chi/jwtauth","clone":"git clone https://github.com/go-chi/jwtauth.git","description":"JWT authentication middleware for Go HTTP services","language":"Go","stars":646,"topics":["jwt","jwtauth","jwt-authentication-middleware","go","http","microservices"],"license":"MIT","category":"auth-billing-email","readme_excerpt":"jwtauth - JWT authentication middleware for HTTP services [![GoDoc Widget]][godoc] The jwtauth http middleware package provides a simple way to verify a JWT token from a http request and send the result down the request context ( context.Context ). Please note, jwtauth works with any Go http router, but resides under the go-chi group for maintenance and organization - its only 3rd party dependency is the underlying jwt library \"github.com/lestrrat-go/jwx\". In a complete JWT-authentication flow, you'll first capture the token from a http request, decode it, verify it and then validate that its correctly signed and hasn't expired - the jwtauth.Verifier middleware handler takes care of all of that. The jwtauth.Verifier will set the context values on keys jwtauth.TokenCtxKey and jwtauth.ErrorCtxKey . Next, it's up to an authentication handler to respond or continue processing after the jwtauth.Verifier . The jwtauth.Authenticator middleware responds with a 401 Unauthorized plain-text payload for all unverified tokens and passes the good ones through. You can also copy the Authenticator and customize it to handle invalid tokens to better fit your flow (ie. with a JSON error response body). By default, the Verifier will search for a JWT token in a http request, in the order: 1. 'Authorization: BEARER T' request header 2. 'jwt' Cookie value The first JWT string that is found as an authorization header or cookie header is then decoded by the lestrrat-go/jwx library and a jwt.Token ob","default_branch":null,"files":null,"tree":[],"storefront":"/r/go-chi","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/go-chi/jwtauth/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}