package org.docksidestage.app.application.security;

import org.springframework.beans.factory.annotation.Autowired;
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.core.userdetails.UserDetailsService;
import org.springframework.security.crypto.password.StandardPasswordEncoder;

/**
 * @author inoue on 2016/12/18.
 * @author jflute
 */
@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {

    @Autowired
    private UserDetailsService userDetailService;

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        // #for_now for test, enable later by jflute
        //http.authorizeRequests()
        //        .antMatchers("/login", "/register")
        //        .permitAll()
        //        .antMatchers("/css/**", "/js/**", "/images/**")
        //        .permitAll()
        //        .antMatchers(HttpMethod.POST, "/login")
        //        .permitAll()
        //        .anyRequest()
        //        .authenticated()
        //        .and()
        //        .formLogin()
        //        .loginProcessingUrl("/login")
        //        .defaultSuccessUrl("/member")
        //        .failureUrl("/")
        //        .usernameParameter("emailAddress")
        //        .passwordParameter("password")
        //        .permitAll()
        //        .loginPage("/login")
        //        .and()
        //        .logout()
        //        .logoutSuccessUrl("/login")
        //        .permitAll()
        //        .and()
        //        .csrf()
        //        .disable();
    }

    @Autowired
    public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
        auth.userDetailsService(userDetailService).passwordEncoder(new StandardPasswordEncoder()); // 既存のsampleプロジェクトに合わせる
    }
}

@@ -1071,18 +1071,16 @@
         
-//
 http.aut
@@ -1096,34 +1096,32 @@
 uests()%0A        
-//
         .antMatc
@@ -1146,16 +1146,51 @@
 egister%22
+, %22/product/list%22, %22/product/list/%22
 )%0A      
@@ -1183,34 +1183,32 @@
 list/%22)%0A        
-//
         .permitA
@@ -1212,34 +1212,32 @@
 itAll()%0A        
-//
         .antMatc
@@ -1276,34 +1276,32 @@
 es/**%22)%0A        
-//
         .permitA
@@ -1317,99 +1317,8 @@
     
-//        .antMatchers(HttpMethod.POST, %22/login%22)%0A        //        .permitAll()%0A        //
     
@@ -1335,34 +1335,32 @@
 quest()%0A        
-//
         .authent
@@ -1371,52 +1371,23 @@
 ed()
-%0A        //        .and()%0A        //        
+;%0A%0A        http
 .for
@@ -1395,34 +1395,32 @@
 Login()%0A        
-//
         .loginPr
@@ -1429,27 +1429,28 @@
 essingUrl(%22/
-log
+sign
 in%22)%0A       
@@ -1442,34 +1442,32 @@
 ignin%22)%0A        
-//
         .default
@@ -1488,34 +1488,32 @@
 ember%22)%0A        
-//
         .failure
@@ -1521,34 +1521,32 @@
 rl(%22/%22)%0A        
-//
         .usernam
@@ -1561,20 +1561,15 @@
 er(%22
-emailAddress
+account
 %22)%0A 
@@ -1567,34 +1567,32 @@
 count%22)%0A        
-//
         .passwor
@@ -1614,34 +1614,32 @@
 sword%22)%0A        
-//
         .permitA
@@ -1643,34 +1643,32 @@
 itAll()%0A        
-//
         .loginPa
@@ -1672,19 +1672,20 @@
 nPage(%22/
-log
+sign
 in%22)%0A   
@@ -1681,34 +1681,32 @@
 ignin%22)%0A        
-//
         .and()%0A 
@@ -1704,34 +1704,32 @@
  .and()%0A        
-//
         .logout(
@@ -1730,34 +1730,32 @@
 ogout()%0A        
-//
         .logoutS
@@ -1774,34 +1774,32 @@
 login%22)%0A        
-//
         .permitA
@@ -1806,88 +1806,8 @@
 ll()
-%0A        //        .and()%0A        //        .csrf()%0A        //        .disable()
 ;%0A  

enable spring security