春季靴身份验证在2022年

发布于 2025-02-11 03:43:44 字数 206 浏览 0 评论 0 原文

我在找出春季启动身份验证方面遇到了麻烦。我是Spring Security的新手,最近 WebSecurityConfigurerAdapter 被弃用了。是否可以解释基本身份验证并具有一些实现的来源?

我找不到满足我要求的东西。我发现的新资源提供了一般性的看法。旧的点是 websecurityconfigureradapter

I have trouble with figuring out Spring Boot authentication. I am new to Spring Security and recently WebSecurityConfigurerAdapter got deprecated. Is there a source where basic authentication is explained and has some implementations of it?

I wasn't able to find something that would satisfy my request. New sources that I found, provided general view on it. The old ones were point at WebSecurityConfigurerAdapter

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

岁吢 2025-02-18 03:43:44

在Spring Security 5.7中,您需要提供 SecurityFilterChain bean。

@Configuration
public class SecurityConfiguration {

    @Bean
    public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
        http
            .authorizeHttpRequests((authz) -> authz
                .anyRequest().authenticated()
            )
            .httpBasic(withDefaults())
            .authenticationManager(new CustomAuthenticationManager());
        return http.build();
    }

}

参考:

In Spring Security 5.7, You need to provide SecurityFilterChain bean.

@Configuration
public class SecurityConfiguration {

    @Bean
    public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
        http
            .authorizeHttpRequests((authz) -> authz
                .anyRequest().authenticated()
            )
            .httpBasic(withDefaults())
            .authenticationManager(new CustomAuthenticationManager());
        return http.build();
    }

}

Reference: https://spring.io/blog/2022/02/21/spring-security-without-the-websecurityconfigureradapter

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文