Vaadin 23 + spring secirty + authentication. How to modify this bean so that I can find if the user

exists in the database. and how to find out username from the loginform in this bean
@Bean
public UserDetailsManager userDetailsService() {
UserDetails user =
User.withUsername(“user”)
.password(“{noop}user”)
.roles(“USER”)
.build();
UserDetails admin =
User.withUsername(“admin”)
.password(“{noop}admin”)
.roles(“ADMIN”)
.build();
return new InMemoryUserDetailsManager(user, admin);
}

Additionally I dont want to use “in memory”

https://docs.spring.io/spring-security/reference/servlet/authentication/passwords/jdbc.html#servlet-authentication-jdbc

thanks for quick reply. I had seen that before but I dont have DataSource set up. i am using service, repository and entity classes to access database. How do I set up DataSource?

thanks. I will check this out. one more question.

how do I get username (from the loginform) in this bean?

You don’t. You provide Spring Security a way to authenticate users by implementing the UserDetailsService interface configure your security setup to use that implementation.

Ok. I will try that out.

Thanks for your help

I will get back to you once I have tested it.

its working now. Thanks