本文介绍了如何配置没有XML文件的Spring ACL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在为我的伺服器新增ACL功能。我已配置spring安全使用java文件,并希望以相同的方式添加ACL。我该怎么办呢?所有的教程我发现使用XML文件。
I am trying to add ACL capabilities to my server. I have configured spring security using java file and would like to add ACL in the same manner. How should I do it? All the tutorials I found used XML file.
SecurityInit:
@Order(1) public class SecurityInitializer extends AbstractSecurityWebApplicationInitializer { }SecurityConfig
SecurityConfig
@EnableWebMvcSecurity @EnableGlobalMethodSecurity(prePostEnabled=true) @Component @ComponentScan(basePackages = {"test.package"}) public class SecurityConfig extends WebSecurityConfigurerAdapter { ... @Autowired protected void registerAuthentication(UserDetailsService userDetailsService, AuthenticationManagerBuilder auth) throws Exception { auth.userDetailsService(userDetailsService); } // stackoverflow/a/21100458/162345 @Override protected void configure(HttpSecurity http) throws Exception { http .csrf().disable() .headers().disable() .addFilterBefore(...) .addFilterBefore(...) // TODO: create a better way to differentiate login to signup .exceptionHandling() .authenticationEntryPoint(noRedirectForAnonymous) .and() .formLogin() .successHandler(restAuthenticationSuccessHandler) .failureHandler(restAuthenticationFailureHandler) .and() .logout() .logoutSuccessHandler(noRedirectLogoutSuccessHandler) .and() .authorizeRequests() .antMatchers("/api/keywords/**").permitAll() .antMatchers("/api/**").authenticated(); } }推荐答案
是没有办法配置spring acl没有xml文件。这在spring文档本身提到。请参阅spring文档。
There is no way to configure spring acl without xml file. This is mentioned in spring docs itself.Refer to spring documentation.
更多推荐
如何配置没有XML文件的Spring ACL
发布评论