Spring Security Web module provides comprehensive web security features for Spring-based applications, including servlet-based authentication, authorization, CSRF protection, session management, and security filter chain implementation
—
Spring Security Web's firewall system provides HTTP request validation, sanitization, and attack prevention through configurable rules that protect against malicious requests.
public interface HttpFirewall {
FirewalledRequest getFirewalledRequest(HttpServletRequest request) throws RequestRejectedException;
HttpServletResponse getFirewalledResponse(HttpServletResponse response);
}
public class StrictHttpFirewall implements HttpFirewall {
public void setAllowUrlEncodedSlash(boolean allowUrlEncodedSlash);
public void setAllowUrlEncodedPercent(boolean allowUrlEncodedPercent);
public void setAllowSemicolon(boolean allowSemicolon);
public void setUnsafeAllowAnyHttpMethod(boolean unsafeAllowAnyHttpMethod);
public FirewalledRequest getFirewalledRequest(HttpServletRequest request);
public HttpServletResponse getFirewalledResponse(HttpServletResponse response);
}
public interface RequestRejectedHandler {
void handle(HttpServletRequest request, HttpServletResponse response,
RequestRejectedException requestRejectedException) throws IOException, ServletException;
}
public class HttpStatusRequestRejectedHandler implements RequestRejectedHandler {
public HttpStatusRequestRejectedHandler(HttpStatus httpStatus);
public void handle(HttpServletRequest request, HttpServletResponse response,
RequestRejectedException requestRejectedException);
}// Configure strict firewall
StrictHttpFirewall firewall = new StrictHttpFirewall();
firewall.setAllowUrlEncodedSlash(false);
firewall.setAllowSemicolon(false);
FilterChainProxy proxy = new FilterChainProxy(chains);
proxy.setFirewall(firewall);
proxy.setRequestRejectedHandler(new HttpStatusRequestRejectedHandler(HttpStatus.BAD_REQUEST));Install with Tessl CLI
npx tessl i tessl/maven-org-springframework-security--spring-security-web