Good afternoon.
I use Spring Security in the context of a downloadable, automatically configured Spring application. My goal is to configure basic auth so that the standard login form of the main browser does not display on 401. From Google, I found out that for this I need to change the default WWW-Authenticate header to something other than Basic xxxxx.
To do this, I declared a filter:
@Bean
@Order(Integer.MAX_VALUE)
public Filter customAuthFilter() {
return new Filter() {
@Override
public void init(FilterConfig fc) throws ServletException {
}
@Override
public void doFilter(ServletRequest sreq, ServletResponse sresp, FilterChain fc) throws IOException, ServletException {
HttpServletRequest req = (HttpServletRequest) sreq;
HttpServletResponse resp = (HttpServletResponse) sresp;
fc.doFilter(req, resp);
log.info("filter");
log.info("status " + resp.getStatus());
if(resp.getStatus() == 401) {
resp.setHeader("WWW-Authenticate", "Client-driven");
}
}
@Override
public void destroy() {
}
};
, ( doFilter). , , - "WWW-Authenticate". , - , , .
- ?