mirror of
https://forgejo.merr.is/annika/jwtauth.git
synced 2025-12-11 13:47:41 -05:00
Refactor jwtauth pkg, move to go-chi org, and support dgrijalva/jwt-go v3
This commit is contained in:
parent
d5f87ca5c3
commit
4c654d77d5
20 changed files with 180 additions and 1350 deletions
|
|
@ -62,9 +62,8 @@ import (
|
|||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/dgrijalva/jwt-go"
|
||||
"github.com/goware/jwtauth"
|
||||
"github.com/pressly/chi"
|
||||
"github.com/go-chi/chi"
|
||||
"github.com/go-chi/jwtauth"
|
||||
)
|
||||
|
||||
var TokenAuth *jwtauth.JwtAuth
|
||||
|
|
@ -99,9 +98,7 @@ func router() http.Handler {
|
|||
r.Use(jwtauth.Authenticator)
|
||||
|
||||
r.Get("/admin", func(w http.ResponseWriter, r *http.Request) {
|
||||
ctx := r.Context()
|
||||
token := ctx.Value("jwt").(*jwt.Token)
|
||||
claims := token.Claims
|
||||
_, claims, _ := jwtauth.TokenContext(r.Context())
|
||||
w.Write([]byte(fmt.Sprintf("protected area. hi %v", claims["user_id"])))
|
||||
})
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue