Using a custom Spring Security filter, I\'d like to return an HTTP 401 error code if the HTTP Header doesn\'t contain a particular key-value pair.
Example:
From the API docs for the doFilter method, you can:
so setting the response status code and returning immediately without invoking chain.doFilter is the best option for what you want to achieve here.