Added UserRepository bean to SecurityConfig for Spring default auth to not log generated password.

This commit is contained in:
Max W. 2024-05-30 12:10:02 +02:00
parent 5df2e1a705
commit fd4f48a57c

View File

@ -8,6 +8,8 @@ import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configurers.LogoutConfigurer;
import org.springframework.security.config.http.SessionCreationPolicy;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.security.web.SecurityFilterChain;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
@ -21,6 +23,12 @@ public class SecurityConfig {
this.jwtAuthenticationFilter = jwtAuthenticationFilter;
}
// This bean is required for Spring Security, though it's not used in this project
@Bean
UserDetailsService emptyDetailsService() {
return username -> { throw new UsernameNotFoundException("no local users, only JWT tokens allowed"); };
}
@Bean
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
http