Answer the question
In order to leave comments, you need to log in
How to give access to all front pages except one?
I need to give access to all pages of the front, but by url api/user/** access should be only for those who have the USER role
@Override
public void configure(HttpSecurity http) throws Exception {
CharacterEncodingFilter filter = new CharacterEncodingFilter();
filter.setEncoding("UTF-8");
filter.setForceEncoding(true);
http
.cors()
.disable()
.csrf()
.disable()
.sessionManagement()
.sessionCreationPolicy(SessionCreationPolicy.STATELESS)
.and()
.authorizeRequests()
.antMatchers(LOGIN_URL).permitAll()
.antMatchers(REGISTRATION_URL).permitAll()
.antMatchers(GET_JWT_URL).permitAll()
.antMatchers(SWAGGER_URL).permitAll()
.antMatchers("api/user/**")
.hasRole("USER")
.anyRequest()
.permitAll();
http.addFilterBefore(JwtAuthFilter(), UsernamePasswordAuthenticationFilter.class);
}
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