使用Spring Boot预授权和自定义AuthenticationFilter

使用Spring Boot预授权和自定义AuthenticationFilter,第1张

使用Spring Boot预授权和自定义AuthenticationFilter

Spring Security一直很繁琐的配置,唯一简单的方法是:

  • 要么成为专家,并准备好研究资源,然后您就可以 手动 做困难的事情 __
  • 或尽可能使用框架中提供的示例(使用文档中的示例)

对于的配置

X509AuthenticationFilter
HttpSecurity
javadoc给出了
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代理的接口连接到控制器。



欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5641512.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-16
下一篇 2022-12-16

发表评论

登录后才能评论

评论列表(0条)

保存