go-chi / jwtauth

JWT authentication middleware for Go HTTP services
MIT License
541 stars 91 forks source link

Allow users to retrieve JWT from a query and cookie with a specified name #89

Open JunNishimura opened 5 months ago

JunNishimura commented 5 months ago

Fixes #88

  1. I defined the function TokenFromCookieWith to retrieve jwt from a cookie with a name passed as an argument.
  2. I defined the function TokenFromQueryWith to retrieve jwt from a query with a name passed as an argument.

How to Use

func Verifier(ja *JWTAuth) func(http.Handler) http.Handler {
    return func(next http.Handler) http.Handler {
        return Verify(ja, TokenFromQueryWith("custom-param"), TokenFromHeader, TokenFromCookieWith("custom-cookie"))(next)
    }
}