I got this error

Global AuthenticationManager configured with an AuthenticationProvider bean. UserDetailsService beans will not be used by Spring Security for automatically configuring username/password login. Consider removing the AuthenticationProvider bean. Alternatively, consider using the UserDetailsService in a manually instantiated DaoAuthenticationProvider. If the current configuration is intentional, to turn off this warning, increase the logging level of 'org.springframework.security.config.annotation.authentication.configuration.InitializeUserDetailsBeanManagerConfigurer' to ERROR
2025-01-29T19:44:52.395+05:30  INFO 13664 --- [ScriptEnhancer] [ main] o.s.d.j.r.query.QueryEnhancerFactory  : Hibernate is in classpath; If applicable, HQL parser will be used.
Global AuthenticationManager configured with an AuthenticationProvider bean. UserDetailsService beans will not be used by Spring Security for automatically configuring username/password login. Consider removing the AuthenticationProvider bean. Alternatively, consider using the UserDetailsService in a manually instantiated DaoAuthenticationProvider. If the current configuration is intentional, to turn off this warning, increase the logging level of 'org.springframework.security.config.annotation.authentication.configuration.InitializeUserDetailsBeanManagerConfigurer' to ERROR
2025-01-29T19:44:52.395+05:30  INFO 13664 --- [ScriptEnhancer] [ main] o.s.d.j.r.query.QueryEnhancerFactory  : Hibernate is in classpath; If applicable, HQL parser will be used.
@Bean
SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
http.cors(cors -> corsFilter()).csrf(csrf -> csrf.disable()) // Disable CSRF for stateless APIs
.authorizeHttpRequests(auth -> auth.requestMatchers("/api/admin/**").hasAuthority("ADMIN").requestMatchers("/api/auth/**").permitAll().anyRequest().authenticated() // Protect all other endpoints
).sessionManagement(sess -> sess.sessionCreationPolicy(SessionCreationPolicy.STATELESS) // No sessions
).exceptionHandling(e -> {
e.authenticationEntryPoint((req, res, ex) -> {
res.sendError(HttpServletResponse.SC_UNAUTHORIZED, ex.getMessage());
}
);
}
).addFilterBefore(jwtFilter, UsernamePasswordAuthenticationFilter.class );
// Add JWT filter
return http.build();
}
@Bean
AuthenticationManager authenticationManager(AuthenticationConfiguration configuration) throws Exception {
return configuration.getAuthenticationManager();
}
@Autowired
protected void configureAuthentication(AuthenticationManagerBuilder auth) throws Exception {
auth.userDetailsService(userDetailsServicImp).passwordEncoder(config.passwordEncoder());
}
@Bean
SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
http.cors(cors -> corsFilter()).csrf(csrf -> csrf.disable()) // Disable CSRF for stateless APIs
.authorizeHttpRequests(auth -> auth.requestMatchers("/api/admin/**").hasAuthority("ADMIN").requestMatchers("/api/auth/**").permitAll().anyRequest().authenticated() // Protect all other endpoints
).sessionManagement(sess -> sess.sessionCreationPolicy(SessionCreationPolicy.STATELESS) // No sessions
).exceptionHandling(e -> {
e.authenticationEntryPoint((req, res, ex) -> {
res.sendError(HttpServletResponse.SC_UNAUTHORIZED, ex.getMessage());
}
);
}
).addFilterBefore(jwtFilter, UsernamePasswordAuthenticationFilter.class );
// Add JWT filter
return http.build();
}
@Bean
AuthenticationManager authenticationManager(AuthenticationConfiguration configuration) throws Exception {
return configuration.getAuthenticationManager();
}
@Autowired
protected void configureAuthentication(AuthenticationManagerBuilder auth) throws Exception {
auth.userDetailsService(userDetailsServicImp).passwordEncoder(config.passwordEncoder());
}
1 Reply
JavaBot
JavaBot2mo ago
This post has been reserved for your question.
Hey @Danix! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here. 💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.

Did you find this page helpful?