(u *url.URL, logger *clog.CondLogger)
| 16 | } |
| 17 | |
| 18 | func NewRejectHTTPAuth(u *url.URL, logger *clog.CondLogger) (*RejectHTTPAuth, error) { |
| 19 | values, err := url.ParseQuery(u.RawQuery) |
| 20 | if err != nil { |
| 21 | return nil, err |
| 22 | } |
| 23 | scheme, _ := strings.CutPrefix(strings.ToLower(u.Scheme), "reject-") |
| 24 | target := &url.URL{ |
| 25 | Scheme: scheme, |
| 26 | User: u.User, |
| 27 | Host: u.Host, |
| 28 | Path: u.Path, |
| 29 | RawPath: u.RawPath, |
| 30 | RawQuery: values.Get("qs"), |
| 31 | } |
| 32 | xf, _ := strconv.ParseBool(values.Get("x-forwarded")) |
| 33 | method := values.Get("method") |
| 34 | return &RejectHTTPAuth{ |
| 35 | proxy: &httputil.ReverseProxy{ |
| 36 | Rewrite: func(r *httputil.ProxyRequest) { |
| 37 | r.SetURL(target) |
| 38 | if xf { |
| 39 | r.SetXForwarded() |
| 40 | } |
| 41 | if method != "" { |
| 42 | r.Out.Method = method |
| 43 | } |
| 44 | }, |
| 45 | }, |
| 46 | }, nil |
| 47 | } |
| 48 | |
| 49 | func (a *RejectHTTPAuth) Validate(ctx context.Context, w http.ResponseWriter, r *http.Request) (string, bool) { |
| 50 | r = r.Clone(ctx) |
no test coverage detected