08-02-2023, 04:34 PM
if you are using **spring boot 3** must be considered that In **Spring Security 5.7.0-M2 the WebSecurityConfigurerAdapter is deprecated**. so you must Upgrade the Deprecated WebSecurityConfigurerAdapter with the correct beans.
Below is an example configuration using the **WebSecurityConfigurerAdapter** that secures all endpoints with HTTP Basic:
@Configuration
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeHttpRequests((authz) -> authz
.anyRequest().authenticated()
)
.httpBasic(withDefaults());
}
}
Going forward, the recommended way of doing this is registering a **SecurityFilterChain** bean:
@Configuration
public class SecurityConfiguration {
@Bean
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
http
.authorizeHttpRequests((authz) -> authz
.anyRequest().authenticated()
)
.httpBasic(withDefaults());
return http.build();
}
}
for more information click [here][1] and [here][2]
[1]:
Below is an example configuration using the **WebSecurityConfigurerAdapter** that secures all endpoints with HTTP Basic:
@Configuration
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeHttpRequests((authz) -> authz
.anyRequest().authenticated()
)
.httpBasic(withDefaults());
}
}
Going forward, the recommended way of doing this is registering a **SecurityFilterChain** bean:
@Configuration
public class SecurityConfiguration {
@Bean
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
http
.authorizeHttpRequests((authz) -> authz
.anyRequest().authenticated()
)
.httpBasic(withDefaults());
return http.build();
}
}
for more information click [here][1] and [here][2]
[1]:
[To see links please register here]
[2]:[To see links please register here]