Closed 2w1nd closed 2 years ago
my token in form-data,but TokenLookup seem no support it
Ha, I just want to raise an issue about this problem. I guess that you have joined the training camp organized by ByteDance also. I modified a function of the 'auth_jwt.go' file as following to add an option to get token from form data in the request body.
func (mw *GinJWTMiddleware) jwtFromForm(c *gin.Context, key string) (string, error) {
token := c.PostForm(key)
if token == "" {return "", ErrEmptyParamToken}
return token, nil
}
func (mw *GinJWTMiddleware) ParseToken(c *gin.Context) (*jwt.Token, error) {
for _, method := range methods {
switch k {
case "header": token, err = mw.jwtFromHeader(c, v)
case "query": token, err = mw.jwtFromQuery(c, v)
case "cookie": token, err = mw.jwtFromCookie(c, v)
case "param": token, err = mw.jwtFromParam(c, v)
case "form": token, err = mw.jwtFromForm(c, v)
}
}
}
yes, you are right, I also participated. I should read the source code carefully😂