Use different paths for public and private resources Jersey + Spring boot

前端 未结 3 1218
离开以前
离开以前 2020-12-16 16:16

I\'m using Spring boot + Jersey + Spring security, I want to have public and private endpoints, I want an schema as follow:

  • /rest -- My root c
3条回答
  •  时光说笑
    2020-12-16 17:13

    The error you are seeing is not related to your security config, you may want to take a look at this ticket, https://github.com/spring-projects/spring-boot/issues/3260

    If you want to permit all traffic to endpoints past /public you can add the RequestMatcher to the Spring Security ignore list.

    @Configuration
    @EnableWebSecurity
    public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
    
        @Override
        public void configure(WebSecurity web) throws Exception {
    
            web.ignoring().antMatchers("/rest/public/**");
         }
    
         protected void configure(HttpSecurity http) throws Exception {
    
              http.authorizeRequests().antMatcher("/rest/private/**")
              .anyRequest().authenticated().and()
              .httpBasic().and()
              .csrf().disable()
         }
    
    }
    

    http://docs.spring.io/spring-security/site/docs/current/reference/htmlsingle/#jc

提交回复
热议问题