使用身份验证提供商不使用spring Security 5.7.0中的WebsecurityConfigurerAdapter
现在,我正在尝试为我的Spring Boot Spring Security项目实现Spring Security身份验证提供商。因此,以前,我们能够在我们的安全配置文件中扩展WebsecurityConfigurerAdapter,以自定义HTTP和httpsececurity HTTP
和AuthenticationManagerBuilder auth
通过覆盖配置。
但是现在(Spring Security 5.7.0)WebsecurityConfigurerAdapter被弃用了,我正在遵循以下内容的WebsecurityCustomizer方法,
@EnableWebSecurity
@Configuration
public class SecurityConfig{
@Bean
public WebSecurityCustomizer webSecurityCustomizer() {
return (web) -> web.ignoring()
.antMatchers("/users/getUser");
}
}
因此在这里使用WebsEcurityCustomizer,我如何在REST API中使用身份验证提供程序功能?谁能指导我解决此问题或请建议更新的文档请参阅?
Now I am trying to implement spring security authentication provider for my spring boot spring security project. So previously we were able to extend WebSecurityConfigurerAdapter in our Security config file to customize the http and HttpSecurity http
and AuthenticationManagerBuilder auth
by overriding configure
.
But now (Spring Security 5.7.0) WebSecurityConfigurerAdapter got deprecated and I am following WebSecurityCustomizer method like the following,
@EnableWebSecurity
@Configuration
public class SecurityConfig{
@Bean
public WebSecurityCustomizer webSecurityCustomizer() {
return (web) -> web.ignoring()
.antMatchers("/users/getUser");
}
}
So Here using WebSecurityCustomizer , how can I use authentication provider functionality in my ReST API ? Can anyone guide me to solve this issue or kindly suggest updated documentation for refer please?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为
WebsecurityCustomizer
是您在这种情况下要使用的BEAN。我想您要做的是配置SecurityFilterChain
,就像:无论如何,不建议在某个端点中禁用Spring Security,替代方法是使用
授权>授权>授权。 AntMatchers(“/my-endpoint”)。如果您不希望在该端点上安全性,请允许()
。关于
Authentication Provider
和AuthenticationManager
,此链接可以为您提供可能遇到的问题。I don't think that the
WebSecurityCustomizer
is the bean that you want to use in this case. I guess that what you are trying to do is to configure aSecurityFilterChain
, like so:Anyways, it is not recommended to disable Spring Security in a certain endpoint, the alternative is to use
authorizeHttpRequests.antMatchers("/my-endpoint").permitAll()
if you don't want security on that endpoint.About the
AuthenticationProvider
andAuthenticationManager
, this link can help you with questions that you may have.