/**
 * <p>Project name is RoomieS<br>
 * Package name is life.theroomie.configration<br>
 * File name is SecurityConfig.java<br>
 *
 * @author YeonGyu Yang
 * @since 2016. 2. 6.
 */
package com.faveroomies.configration;

import org.apache.tomcat.jdbc.pool.DataSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
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.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;

/**
 * 
 * @author YeonGyu Yang
 * @Since 2016. 2. 6.
 *
 */
@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {

	@Autowired
	private DataSource dataSource;

	@Override
	protected void configure(HttpSecurity http) throws Exception {

		http.authorizeRequests().antMatchers("/").permitAll().anyRequest().permitAll().and().formLogin()
				.loginPage("/login").defaultSuccessUrl("/").permitAll().and().logout().logoutSuccessUrl("/")
				.permitAll().and().csrf().disable();
	}

	@Autowired
	public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
		auth.jdbcAuthentication().dataSource(dataSource).passwordEncoder(passwordEncoder())
				.usersByUsernameQuery("select username, password, enabled from auth where username = ?")
				.authoritiesByUsernameQuery("select username, role from auth where username = ?");
	}

	@Bean
	public PasswordEncoder passwordEncoder(){
		PasswordEncoder encoder = new BCryptPasswordEncoder();
		return encoder;
	}
}


@@ -1284,24 +1284,40 @@
 Matchers(%22/%22
+, %22/register/**%22
 ).permitAll(
@@ -1331,33 +1331,37 @@
 quest().
-permitAll
+authenticated
 ().and()
 .formLog
@@ -1352,16 +1352,21 @@
 ().and()
+%0A%09%09%09%09
 .formLog
@@ -1369,21 +1369,16 @@
 mLogin()
-%0A%09%09%09%09
 .loginPa
@@ -1503,16 +1503,17 @@
 able();%0A
+%0A
 %09%7D%0A%0A%09@Au
@@ -1603,16 +1603,17 @@
 ption %7B%0A
+%0A
 %09%09auth.j
@@ -1870,16 +1870,17 @@
  = ?%22);%0A
+%0A
 %09%7D%0A%0A%09@Be
@@ -1923,18 +1923,20 @@
 ncoder()
+ 
 %7B%0A
+%0A
 %09%09Passwo
@@ -2006,10 +2006,9 @@
 er;%0A
+%0A
 %09%7D%0A
+
 %7D
-%0A%0A

Update Configration