For a library or for compliance purposes you may want to apply a consistent spring security configuration
Spring Security 7
You can achieve this with a Customizer<HttpSecurity> Bean
Please refer to Modular HttpSecurity Configuration for documentation and examples