package com.zombie.config;

import org.springframework.context.annotation.Bean;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.provisioning.InMemoryUserDetailsManager;

@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {

	@Bean
	public UserDetailsService userDetailsService() {
		InMemoryUserDetailsManager manager = new InMemoryUserDetailsManager();
		manager.createUser(User.withUsername("user").password("password").roles("USER").build());
		return manager;
	}
}
@@ -21,16 +21,46 @@
 onfig;%0A%0A
+import javax.sql.DataSource;%0A%0A
 import o
@@ -82,15 +82,21 @@
 ork.
-context
+beans.factory
 .ann
@@ -103,20 +103,25 @@
 otation.
-Bean
+Autowired
 ;%0Aimport
@@ -137,39 +137,31 @@
 ngframework.
-security.config
+context
 .annotation.
@@ -152,37 +152,33 @@
 text.annotation.
-web.c
+C
 onfiguration.Ena
@@ -177,26 +177,8 @@
 tion
-.EnableWebSecurity
 ;%0Aim
@@ -233,596 +233,731 @@
 ion.
-web.configuration.WebSecurityConfigurerAdapter;%0Aimport org.springframework.security.core.userdetails.User;%0Aimport org.springframework.security.core.userdetails.UserDetailsService;%0Aimport org.springframework.security.provisioning.InMemoryUserDetailsManager;%0A%0A@EnableWebSecurity%0Apublic class WebSecurityConfig extends WebSecurityConfigurerAdapter %7B%0A%0A%09@Bean%0A%09public UserDetailsService userDetailsService() %7B%0A%09%09InMemoryUserDetailsManager manager = new InMemoryUserDetailsManager();%0A%09%09manager.createUser(User.withUsername(%22user%22).password(%22password%22).roles(%22USER%22).build());%0A%09%09return manager
+authentication.builders.AuthenticationManagerBuilder;%0Aimport org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;%0Aimport org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;%0A%0A@Configuration%0A@EnableWebSecurity%0Apublic class WebSecurityConfig extends WebSecurityConfigurerAdapter %7B%0A%09@Autowired%0A%09DataSource dataSource;%0A%0A%09@Autowired%0A%09public void configAuthentication(AuthenticationManagerBuilder auth) throws Exception %7B%0A%09%09auth.jdbcAuthentication().dataSource(dataSource)%0A%09%09%09%09.usersByUsernameQuery(%22select username,password, enabled from users where username=?%22)%0A%09%09%09%09.authoritiesByUsernameQuery(%22select username, role from user_roles where username=?%22)
 ;%0A%09%7D%0A%7D
+%0A

add JDBC to spring security, login information stored in database