Answer the question
In order to leave comments, you need to log in
Why does Spring Security refuse to let in despite permitall()?
I want authorization to be required only for the url where the word admin occurs. Now gives error Unauthorized everywhere.
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.csrf().disable()
.httpBasic()
.and()
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS)
.and()
.headers().frameOptions().disable()
.and()
.authorizeRequests()
.antMatchers("**/admin/**").hasRole(Role.ADMIN.getAuthority())
.anyRequest().permitAll();
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question