Documentation ¶
Index ¶
- Constants
- Variables
- func AuthPlugin(handler middleware.Handler) middleware.Handler
- func CreateToken(secretKey []byte, username, email, phoneNumber string, ...) (string, error)
- func NewJWTFunc(secretKey []byte) func(token *jwtv4.Token) (interface{}, error)
- func NewWhiteListMatcher(whiteList map[string]bool) selector.MatchFunc
- type CurrentUser
- type CustomClaims
Constants ¶
View Source
const (
Issuer = "xuanwu wan199406@gmail.com"
)
Variables ¶
View Source
var (
SigningMethod = jwtv4.SigningMethodHS256
)
Functions ¶
func AuthPlugin ¶
func AuthPlugin(handler middleware.Handler) middleware.Handler
AuthPlugin get jwt claims from context and put CurrentUser into it.
func CreateToken ¶
Types ¶
type CurrentUser ¶
type CurrentUser struct { Username string `json:"username"` Email string `json:"email"` PhoneNumber string `json:"phoneNumber"` ExtraInfo map[string]interface{} `json:"extraInfo"` }
func FromContext ¶
func FromContext(ctx context.Context) (CurrentUser, error)
type CustomClaims ¶
type CustomClaims struct { User CurrentUser `json:"user"` jwtv4.RegisteredClaims }
Click to show internal directories.
Click to hide internal directories.