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.
But if I throw an exception inside of ForwardedRequestInterceptor that has @ResponseStatus(HttpStatus.UNAUTHORIZED) then the TraceFilter bombs and I get a 500 back.
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 theReverseProxyFilter
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 theTraceFilter
bombs and I get a 500 back.o.s.c.sleuth.instrument.web.TraceFilter : Uncaught exception thrown