Performance: Spring Security auto-configuration
This affects the initial page load speed and backend response time by adding security filters and processing overhead.
Jump into concepts and practice - no test required
Customize security configuration to exclude static resources and disable CSRF where not needed, reducing filter chain length.
spring-boot-starter-security dependency added with no customization, enabling all default filters and CSRF protection on all endpoints.
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Default auto-configuration with all filters | N/A (server-side) | N/A | Increases backend response delay | [X] Bad |
| Customized security config excluding static resources | N/A (server-side) | N/A | Reduces backend response delay | [OK] Good |
spring-boot-starter-security to a Spring Boot project without any additional configuration?exclude attribute in @SpringBootApplication.SecurityAutoConfiguration.class.spring-boot-starter-security added and no custom security config, what will happen when a user accesses /hello endpoint? @RestController
public class HelloController {
@GetMapping("/hello")
public String hello() {
return "Hello World";
}
}spring-boot-starter-security but your application fails to start with a bean creation error related to AuthenticationManager. What is the likely cause?SecurityFilterChain, Spring Boot no longer auto-configures AuthenticationManager.AuthenticationManager bean to satisfy dependencies./public/** endpoints but secure all others with form login. Which configuration snippet correctly achieves this?SecurityFilterChain bean for custom rules.authorizeHttpRequests().requestMatchers("/public/**").permitAll().anyRequest().authenticated().and().formLogin() correctly sets these rules.SecurityFilterChain bean with http.authorizeHttpRequests().requestMatchers("/public/**").permitAll().anyRequest().authenticated().and().formLogin(). [OK]