Imagine that the security config enforces the following access rules:
Java
@Bean
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
return http
.authorizeHttpRequests(auth -> auth
.requestMatchers("/products").permitAll()
.requestMatchers("/home").anonymous()
.requestMatchers("/history").hasAuthority("ROLE_ADMIN")
.requestMatchers("/api/*").authenticated()
.requestMatchers("/api/orders").hasRole("USER")
.requestMatchers("/**").denyAll()
)
.httpBasic(Customizer.withDefaults())
.build();
}
Kotlin
@Bean
fun securityFilterChain(http: HttpSecurity): SecurityFilterChain =
http
.authorizeHttpRequests { auth -> auth
.requestMatchers("/products").permitAll()
.requestMatchers("/home").anonymous()
.requestMatchers("/history").hasAuthority("ROLE_ADMIN")
.requestMatchers("/api/*").authenticated()
.requestMatchers("/api/orders").hasRole("USER")
.requestMatchers("/**").denyAll()
}
.httpBasic(Customizer.withDefaults())
.build()
}
Select all correct statements about accessing the protected endpoints.