spring-boot - 在不扩展 WebSecurityConfigurerAdapter 的情况下访问 Global AuthenticationManagerBuilder?
问题描述
我正在使用spring-authorization-server。我已经按照示例中所示的方式配置了它,SecurityFilterChain
而不是像示例中那样扩展WebSecurityConfigurerAdapter
它,例如
@Bean
SecurityFilterChain defaultSecurityFilterChain(HttpSecurity http) throws Exception {
http
.authorizeRequests(authorizeRequests ->
authorizeRequests.anyRequest().authenticated()
)
.formLogin(withDefaults());
return http.build();
}
现在的问题是:如何访问AuthenticationManagerBuilder
以添加自定义AuthenticationProvider
?(不使用WebSecurityConfigurerAdapter
; 因为我不能将它与 a 一起使用SecurityFilterChain
)
我已经配置了带有 JWT 的 OAuth,现在我正在尝试添加 SAML 支持,但我相信我需要访问全局AuthenticationManagerBuilder
才能添加我的 SAMLAuthenticationProvider
并将构建的内容公开AuthenticationManager
为 bean,以便在我的配置中进一步使用。
我看到它完成的唯一方法是通过覆盖WebSecurityConfigurerAdapter
的方法。
例如
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
private CustomAuthenticationProvider authProvider;
@Bean
@Override
public AuthenticationManager authenticationManagerBean() throws Exception {
return super.authenticationManagerBean();
}
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.authenticationProvider(authProvider);
}
}
有没有办法在AuthenticationManager
不扩展的情况下配置和访问 bean WebSecurityConfigurerAdapter
?
解决方案
推荐阅读
- css - 在 SVG 路径上有延迟的多个 CSS 关键帧动画
- derby - 无法在 derby 10.13.1.1 中获取正确的下一个序列值
- html - 100vh 页面上的 Flexbox 布局(换行),带有可缩放的内面板
- node.js - 在 Firebase 托管项目中使用节点模块的正确方法
- ruby-on-rails - 如何在rails中制作可变路线
- php - 如何使用 php 上传 .pdf 和 .docx 文件以及表单中的图像
- python - Python error. ImportError: No module named feature_format
- sql - SQL oracle如何删除空行以使用get方法
- android - 我想在 Android 中将 Edit Text 的文本转换为 Docx
- c# - 有没有办法我可以随时在桌面上绘制透明的 WPF 应用程序?