Spring Security一直很繁琐的配置,唯一简单的方法是:
- 要么成为专家,并准备好研究资源,然后您就可以 手动 做困难的事情 __
- 或尽可能使用框架中提供的示例(使用文档中的示例)
对于的配置
X509AuthenticationFilter,
HttpSecurityjavadoc给出了
x509以下示例的方法(适用于您的配置-
有关原始示例,请参见javadoc):
@Configuration@EnableWebMvcSecurity@EnableGlobalMethodSecurity(prePostEnabled = true)public class SecurityConfiguration extends WebSecurityConfigurerAdapter { @Override protected void configure(HttpSecurity http) throws Exception { http .authorizeRequests().anyRequest().permitAll() // Example x509() configuration .x509(); } }
带有以下指示:方法返回
X509Configurer进一步的自定义。
除非您有充分的理由做不同的事情(如果是这样,请说出来),我强烈建议您坚持使用该方法。
但是在控制器上使用post-
post注解确实是一个坏主意,因为可以直接在
HttpSecurity配置中完成。它迫使您使用
proxyTargetClass = true。
之前和之后的注释通常应用于不需要的服务层方法,
proxyTargetClass=true因为服务通常通过允许JDK代理的接口连接到控制器。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)