enhance this code by adding proper comments so freshers can understand @Configuration…
- User
enhance this code by adding proper comments so freshers can understand @Configuration @EnableWebSecurity public class SecurityConfig {
code@Bean public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception { // 2 ways of disabling csrf// http.csrf(AbstractHttpConfigurer::disable); http.csrf(customizer -> customizer.disable()); // Enabling the login protection again http.authorizeHttpRequests(request -> request.anyRequest().authenticated()); // Enabling the default spring security again with defaults http.formLogin(Customizer.withDefaults()); // But in postman, in response we will get html of loginform, so to prevent that http.httpBasic(Customizer.withDefaults()); return http.build(); } }
- Assistant