package authz import ( "fmt" "net/http" "strings" "github.com/lestrrat-go/jwx/v3/jwt" ) func TokenFrom(r *http.Request) jwt.Token { authorization := r.Header.Get("Authorization") if authorization == "" || !strings.Contains(authorization, "Bearer") { return jwt.New() } token, err := jwt.ParseRequest(r, jwt.WithContext(r.Context()), jwt.WithHeaderKey("Authorization"), jwt.WithValidate(false), // TODO:: Connect this to a JSON Web Key Set jwt.WithVerify(false), // TODO:: Connect this to a JSON Web Key Set ) if err != nil { fmt.Printf("error: %v\n", err) return jwt.New() } return token }