我有以下spring security java配置规则(版本3.2.4),它有效:
http.antMatcher("/lti1p/**") .addFilterBefore(ltioAuthProviderProcessingFilter, UsernamePasswordAuthenticationFilter.class) .authorizeRequests().anyRequest().hasRole("LTI") .and().csrf().disable();
但是,我想将此规则应用于2个路径("/ lti1p/"和("/ lti2p / ").我不能只用antMatcher替换antMatcher(HttpSecurity对象不允许),当我尝试某些东西时像这样它不再正确地应用规则.
http .addFilterBefore(ltioAuthProviderProcessingFilter, UsernamePasswordAuthenticationFilter.class) .authorizeRequests() .antMatchers("/lti1p/**","/lti2p/**").hasRole("LTI") .and().csrf().disable();
我试过了很多变种而没有任何运气.有没有人知道使用java配置将此规则应用于多个路径的正确方法?
尝试以下方法:
http .requestMatchers() .antMatchers("/lti1p/**","/lti2p/**") .and() .addFilterBefore(ltioAuthProviderProcessingFilter, UsernamePasswordAuthenticationFilter.class) .authorizeRequests().anyRequest().hasRole("LTI") .and().csrf().disable();