Registry / auth / go-chi-jwtauth-v5

go-chi-jwtauth-v5

JSON →
library5.4.0gogounverified

JWT authentication middleware for the Chi router, supporting token parsing and validation.

go get github.com/go-chi/jwtauth/v5
INSTALL
IMPORT
SIG · GO-CHI-JWTAUTH-V5
G
go-chi-jwtauth-v5
authgov5.4.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

jwtauth
github.com/go-chi/jwtauth/v5

Set up JWT authentication middleware on a Chi router.

package main import ( "net/http" "github.com/go-chi/chi/v5" "github.com/go-chi/jwtauth/v5" ) func main() { r := chi.NewRouter() tokenAuth := jwtauth.New("HS256", []byte("secret"), nil) r.Use(jwtauth.Verifier(tokenAuth)) r.Get("/protected", func(w http.ResponseWriter, r *http.Request) { _, claims, _ := jwtauth.FromContext(r.Context()) w.Write([]byte(claims["sub"].(string))) }) http.ListenAndServe(":8080", r) }
Debug
Known issues
breakingBreaking changes between v4 and v5: the package path changed from /v4 to /v5 and some API signatures were updated.
fix
Update import paths and review the migration guide when upgrading from v4.
affects: >=5.0.0
Upgrade
Version history
5.4.0latest on pkg.go.dev
Audit
Dependencies

No dependency data recorded yet.

Agent activity
26 hits · last 30 days
node
26
Resources
go-chi-jwtauth-v5 — go get go-chi-jwtauth-v5 · libregistry