I have a sprig boot application and a neo4J database. My application.properties file looks like this:
spring.data.neo4j.uri = http://127.0.0.1:7474
spring.data.neo4j.username = neo4j
spring.data.neo4j.password = neo4jpass
The application has a basic user:
@NodeEntity
public class User {
@GraphId
private Long id;
@Property (name="username")
private String username;
@Property (name="password")
private String password;
@Property (name="name")
private String name;
@Property (name="role")
private String role;
}
A simple user repository:
public interface UserRepository extends GraphRepository<User>{
}
My current spring security configuration is:
@Configuration
@EnableWebSecurity
public class SpringSecurityConfiguration extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/","/index").permitAll()
.anyRequest().authenticated()
.and()
.authorizeRequests()
.antMatchers("/css/**”)
.permitAll()
.and()
.authorizeRequests()
.antMatchers("/resources/**")
.permitAll();
http
.formLogin()
.loginPage("/login")
.defaultSuccessUrl("/home")
.permitAll()
.and()
.logout()
.permitAll();
}
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth
.inMemoryAuthentication()
.withUser("user").password("password").roles("USER");
}
@Override
public void configure(final WebSecurity web) throws Exception {
web.ignoring()
.antMatchers("/vendors/**", "/local/**");
}
After logging in with the in memory authentication I can create, read and delete users. What I want to do is to replace the in memory authentication, and authenticate against the existing users within the database. What are my options here?