update go-chi/jwtauth to v4
This commit is contained in:
parent
81ddc99f80
commit
b20e15625b
7 changed files with 66 additions and 41 deletions
|
|
@ -2,18 +2,20 @@ package jwt
|
|||
|
||||
import (
|
||||
"errors"
|
||||
"github.com/go-chi/jwtauth"
|
||||
|
||||
"github.com/dgrijalva/jwt-go"
|
||||
)
|
||||
|
||||
// AppClaims represent the claims parsed from JWT access token.
|
||||
type AppClaims struct {
|
||||
ID int
|
||||
Sub string
|
||||
Roles []string
|
||||
ID int `json:"id,omitempty"`
|
||||
Sub string `json:"sub,omitempty"`
|
||||
Roles []string `json:"roles,omitempty"`
|
||||
jwt.StandardClaims
|
||||
}
|
||||
|
||||
// ParseClaims parses JWT claims into AppClaims.
|
||||
func (c *AppClaims) ParseClaims(claims jwtauth.Claims) error {
|
||||
func (c *AppClaims) ParseClaims(claims jwt.MapClaims) error {
|
||||
id, ok := claims["id"]
|
||||
if !ok {
|
||||
return errors.New("could not parse claim id")
|
||||
|
|
@ -42,13 +44,15 @@ func (c *AppClaims) ParseClaims(claims jwtauth.Claims) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// RefreshClaims represent the claims parsed from JWT refresh token.
|
||||
// RefreshClaims represents the claims parsed from JWT refresh token.
|
||||
type RefreshClaims struct {
|
||||
Token string
|
||||
ID int `json:"id,omitempty"`
|
||||
Token string `json:"token,omitempty"`
|
||||
jwt.StandardClaims
|
||||
}
|
||||
|
||||
// ParseClaims parses the JWT claims into RefreshClaims.
|
||||
func (c *RefreshClaims) ParseClaims(claims jwtauth.Claims) error {
|
||||
func (c *RefreshClaims) ParseClaims(claims jwt.MapClaims) error {
|
||||
token, ok := claims["token"]
|
||||
if !ok {
|
||||
return errors.New("could not parse claim token")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue