在这里遇到春季安全问题:
我需要:
/new-pathx/**
与基本身份验证/health
允许所有。我是这样做的:
protected void configure(HttpSecurity http) throws Exception {
http
.antMatcher("/new-pathx/**")
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and()
.csrf().disable()
.httpBasic().and()
.authorizeRequests()
.antMatchers("/health").permitAll()
.anyRequest()
.authenticated();
}
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth
.inMemoryAuthentication()
.withUser(apiUser)
.password(passwordEncoder.encode(apiPassword))
.roles("API_USER");
}
Works OK for the
/new-pathx/**
I can only enter with the user and password.但是我可以在没有任何身份验证的情况下进入任何其他路径。
我的代码有什么问题?