У меня есть два типа URL, один из которых защищен, а другой не защищен, например, регистрация и входи безопасность.
Ниже приведен мой код конфигурации безопасности, но он не работает.
@EnableGlobalMethodSecurity(prePostEnabled = true)
@EnableWebSecurity
@Configuration
public class AppSecurity extends WebSecurityConfigurerAdapter
{
@Autowired
private CustomUserDetailsService userDetailsService;
@Autowired
TempTokenGenerator tempTokenGenerator;
@Bean
@Override
public AuthenticationManager authenticationManagerBean() throws Exception {
return super.authenticationManagerBean();
}
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.userDetailsService(userDetailsService)
.passwordEncoder(getPasswordEncoder());
}
public void configure(WebSecurity web) throws Exception {
web.ignoring().antMatchers("notsecured/signin");
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http.cors().and().csrf().disable().sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS);
http.authorizeRequests()
.antMatchers("/","**secured/**").authenticated()
.and().logout().permitAll()
.and()
.apply(new TempConfigurer(tempTokenGenerator));
}
@Bean
CorsConfigurationSource corsConfigurationSource() {
final UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
source.registerCorsConfiguration("/**", new CorsConfiguration().applyPermitDefaultValues());
return source;
}
что мне не хватает?Что мне нужно сделать, чтобы включить «защищенные» URL-адреса в аутентификацию и фильтры, исключив «незащищенные» из аутентификации и фильтра.1014 *
http.authorizeRequests() to make secured urls work.
и если я поставлю
.antMatchers("/","**/secured/**").authenticated()
с
.anyRequest().permitAll()
, это тоже не работает.