授权除基本身份验证以外的所有URL

时间:2018-09-28 14:08:17

标签: spring-security basic-authentication

我想授权所有REST调用,除了路径中带有“ hello”的任何内容。但是,我所有的PUT调用都被“禁止”。 我在这里想念什么?

image.setImageResource(array[i])

}

@Configuration
@EnableWebSecurity
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {

@Autowired
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
    auth.inMemoryAuthentication().withUser("user1").password(passwordEncoder().encode("user1Pass"))
            .authorities("USER");

}

@Override
protected void configure(HttpSecurity http) throws Exception {
    http.authorizeRequests().antMatchers("/**/hello").authenticated().anyRequest().permitAll().and().httpBasic();
}

@Bean
public PasswordEncoder passwordEncoder() {
    return new BCryptPasswordEncoder();
}

0 个答案:

没有答案