mkopylec / charon-spring-boot-starter

Reverse proxy implementation in form of a Spring Boot starter.
Apache License 2.0
247 stars 55 forks source link

Is there a way how to add custom headers for proxied requests? #40

Closed dmarko484 closed 6 years ago

dmarko484 commented 6 years ago

We would like to integrate Grafana using 'authproxy' feature with our SpringBoot app see https://grafana.com/blog/2015/12/07/grafana-authproxy-have-it-your-way/ ... to share authentication Grafana requires custom header (X-WEBAUTH-USER) to be forwarder with proxied request. Is there a way how to add custom header like this?

mkopylec commented 6 years ago

Hi, Charon proxies the whole requests, including HTTP headers, so you can add the authentication header to the request that must be proxied by Charon. Currently there is no support for adding custom headers to the forwarded request. Let me know if you definitely need such a feature and I will implement it.

dmarko484 commented 6 years ago

Thanks for info. my scenario is like this:

You say "Charon proxies the whole requests, including HTTP headers, so you can add the authentication header to the request that must be proxied by Charon." ... How can I do it prior request is proxied to backround service(Grafana)?

mkopylec commented 6 years ago

Ok, I understand now, you need a support for adding custom headers on Charon level. There is no such feature for now, I will implement it and let you know.

dmarko484 commented 6 years ago

Unbelievable ... Thanks!

mkopylec commented 6 years ago

I have released new 2.2.0 version of Charon which is capable of resolving your issue, see: https://github.com/mkopylec/charon-spring-boot-starter#forwarded-request-intercepting To add your authorization header:

@Component
public class CustomForwardedRequestInterceptor implements ForwardedRequestInterceptor {

    @Override
    public void intercept(RequestData data) {
        data.getHeaders().set("X-WEBAUTH-USER", ...);
    }
}
mkopylec commented 6 years ago

Please close the issue if your problem is solved now.

dmarko484 commented 6 years ago

It's working great! Thanks a lot!