最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

After spring boot update to 3.3.8 authentication basic stopped working - Stack Overflow

programmeradmin1浏览0评论

After I updated spring boot to 3.3.8 my basic authentication for swagger UI stopped working. Any ideas how to fix or why it stopped working? Tnx

Below is code I use to set it

  @Configuration
    @Order(1)
    public static class ApiDocsWebSecurityConfig {
        @Value("${swagger.security.user.name}")
        private String username;

        @Value("${swagger.security.user.password}")
        private String password;

        @Bean
        public SecurityFilterChain configureOpenApiSecurity(HttpSecurity http) throws Exception {
            return globalSecurityConfig(http)
                    .securityMatcher(OPENAPI_WS)
                    .authorizeHttpRequests(authorize -> authorize.anyRequest().authenticated())
                    .userDetailsService(userDetailsService())
                    .httpBasic(Customizer.withDefaults())
                    .build();
        }

        private UserDetailsService userDetailsService() {
            UserDetails user = User
                    .withUsername(username)
                    .password("{noop}" + password)
                    .roles("DOCS")
                    .build();

            return new InMemoryUserDetailsManager(user);
        }
}
发布评论

评论列表(0)

  1. 暂无评论