I'm using spring-boot-starter-security
that automatically secures all of my @GetMapping
rest endpoints by default.
Question: how can I explicit only whitelist a subpath that should not be secured?
I tried as follows:
@Configuration
public class DocumentsSecurityConfiguration implements WebSecurityConfigurer<WebSecurity> {
@Override
public void init(WebSecurity builder) { }
//should allow unauthenticated access
@Override
public void configure(WebSecurity web) {
web.ignoring().antMatchers("/documents/**");
}
}
BUT: the localhost:8080/documents
root path should remain secured. Only subpaths like /documents/123
should remain open.
Problem: When I now access the root path /documents
, it is not secured anymore.
Is my AntMatcher
wrong?