Closed unitrq closed 7 years ago
Casting token pointer value retrieved from request context fails for no obvious reason:
func accCtx(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { ctx := r.Context() val := ctx.Value("jwt") log.Printf("%#v\n", val) t, ok := val.(*jwt.Token) if !ok { errBadRequest(w) return } newctx := context.WithValue(ctx, ctxAccountID, t.Claims["account_id"]) next.ServeHTTP(w, r.WithContext(newctx)) }) }
The Printf call above displays something that looks like valid jwt.Token reference:
&jwt.Token{Raw:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhY2NvdW50X2lkIjoiYTIxZjE4YjQtMGI0Mi00ZDdhLWJkNDAtMmI0ZTZkNGZlYTdjIiwidXNlcl9pZCI6ImQxMWQwOTZkLTc0N2ItNGYyNS05NjcxLWJhNzJjNjM3NTY0YSJ9.ERX3v2mVL_AQu3_nYj7e4xkeXse6VNKR_FcZm8qvQ-A", Method:(*jwt.SigningMethodHMAC)(0xc4200ce760), Header:map[string]interface {}{"alg":"HS256", "typ":"JWT"}, Claims:map[string]interface {}{"account_id":"a21f18b4-0b42-4d7a-bd40-2b4e6d4fea7c", "user_id":"d11d096d-747b-4f25-9671-ba72c637564a"}, Signature:"ERX3v2mVL_AQu3_nYj7e4xkeXse6VNKR_FcZm8qvQ-A", Valid:true}
However, casting that value to *jwt.Token fails.
Is this vendor/ issue, as in https://github.com/goware/jwtauth/issues/14 ?
It is indeed, sorry for duplicating existing issue
No worries.
Casting token pointer value retrieved from request context fails for no obvious reason:
The Printf call above displays something that looks like valid jwt.Token reference:
However, casting that value to *jwt.Token fails.