如何在没有 XML 文件的情况下配置 Spring ACL [英] How to configure Spring ACL without XML file

查看:45
本文介绍了如何在没有 XML 文件的情况下配置 Spring ACL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试向我的服务器添加 ACL 功能.我已经使用 java 文件配置了 spring security,并希望以相同的方式添加 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.

安全初始化:

@Order(1)
public class SecurityInitializer extends AbstractSecurityWebApplicationInitializer {
}

安全配置

@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);
    }

//  http://stackoverflow.com/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();
    }
}

推荐答案

没有xml文件是没有办法配置spring acl的.这在 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆