content: package com.os.china.config;
  
  import com.os.china.service.CustomerUserService;
  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.WebSecurityConfigurerAdapter;
  import org.springframework.security.core.userdetails.UserDetailsService;
  
  /**
   * @author ZhangPengFei
   * @Discription
   * @Data 2017-3-17
   * @Version 1.0.0
   */
  @Configuration
  public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
  
  	@Bean
  	UserDetailsService customerUserService(){
  		return new CustomerUserService();
  	}
  
  	@Override
  	protected void configure(AuthenticationManagerBuilder auth) throws Exception {
  		auth.userDetailsService(customerUserService());
  	}
  
  	@Override
  	protected void configure(HttpSecurity http) throws Exception {
  		http.authorizeRequests()
  				.anyRequest().authenticated()
  				.and()
  				.formLogin()
  				.loginPage("/login")
  				.failureUrl("/login?error")
  				.permitAll()
  				.and()
  				.logout()
  				.permitAll();
  	}
  }
  