Allow to send the auth header for resource requests
@@ -145,15 +145,18 @@ func (b *Backend) RoundTrip(req *http.Request) (*http.Response, error) {
}
}
- if is, ok := req.Context().Value(request.IsResourceReq).(bool); ok && is {
- if beresp.StatusCode == http.StatusUnauthorized {
+ var isResourceReq bool
+ if is, ok := req.Context().Value(request.IsResourceReq).(bool); ok {
+ isResourceReq = is
+ }
+
+ if isResourceReq && beresp.StatusCode == http.StatusUnauthorized {
if memStore, ok := req.Context().Value(request.TokenEndpoint).(*cache.MemoryStore); ok {
if key, ok := req.Context().Value(request.TokenKey).(string); ok && key != "" {
memStore.Del(key)
}
}
}
- }
if b.openAPIValidator != nil {
if err = b.openAPIValidator.ValidateResponse(beresp); err != nil {
@@ -173,6 +176,15 @@ func (b *Backend) RoundTrip(req *http.Request) (*http.Response, error) {
removeConnectionHeaders(req.Header)
}
+ // FIXME:
+ // for _, key := range headerBlacklist {
+ // if isResourceReq && strings.ToLower(key) == "authorization" {
+ // continue
+ // }
+
+ // headerCtx.Del(key)
+ // }
+
// Backend response context creates the beresp variables in first place and applies this context
// to the current beresp obj. Downstream response context evals reading their beresp variable values
// from this result. Fallback case is for testing purposes.
