У меня есть загрузочное приложение sprig и база данных neo4J. Мой файл application.properties выглядит так:
spring.data.neo4j.uri = https://127.0.0.1:7474
spring.data.neo4j.username = neo4j
spring.data.neo4j.password = neo4jpass
Приложение имеет базового пользователя:
@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;
}
Простой пользовательский репозиторий:
public interface UserRepository extends GraphRepository<User>{
}
Моя текущая конфигурация безопасности Spring:
@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/**");
}
После входа в систему с аутентификацией в памяти я могу создавать, читать и удалять пользователей. Что я хочу сделать, так это заменить аутентификацию в памяти и аутентифицировать существующих пользователей в базе данных. Каковы мои варианты здесь?