mkopylec / charon-spring-boot-starter

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

`ForwardedRequestInterceptor` question #56

Closed michaelmccaskill closed 6 years ago

michaelmccaskill commented 6 years ago

I'm looking at using this starter but I need to be able to enforce a valid Bearer token is in the Authorization header. If so I can call a custom service to validate the token. If it's not valid I want to stop the forward from happening. I realize I could simply write another filter and have it execute prior to the ReverseProxyFilter but the problem is I need to set certain headers with values that come from the result of the validation call. What's the best approach here? If I use a separate filter I end up calling the same service twice.

AuthenticationFilter -> AuthenticationService.validateToken ReverseProxyFilter -> AuthenticationService.validateToken

But if I throw an exception inside of ForwardedRequestInterceptor that has @ResponseStatus(HttpStatus.UNAUTHORIZED) then the TraceFilter bombs and I get a 500 back.

o.s.c.sleuth.instrument.web.TraceFilter : Uncaught exception thrown

michaelmccaskill commented 6 years ago

Closing because you don't use TraceFilter. Looks like it's something else that's pulling this in. This isn't a valid issue.