fengxiang
2018-01-11 2ea90fc83051b92d242b87c887336890578a0a30
src/main/java/com/moral/security/WebSecurityConfiguration.java
@@ -14,6 +14,7 @@
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.NoOpPasswordEncoder;
import org.springframework.security.oauth2.provider.ClientDetailsService;
import org.springframework.security.oauth2.provider.approval.ApprovalStore;
import org.springframework.security.oauth2.provider.approval.TokenApprovalStore;
@@ -44,15 +45,15 @@
            .withUser("bill").password("abc123").roles("ADMIN").and()
            .withUser("bob").password("abc123").roles("USER");
//      auth.userDetailsService(userDetailsService).passwordEncoder(new Md5PasswordEncoder());
      auth.userDetailsService(userDetailsService).passwordEncoder(NoOpPasswordEncoder.getInstance());
   }
    @Override
    protected void configure(HttpSecurity http) throws Exception {
      http
      .anonymous().disable()
        .authorizeRequests()
        .antMatchers("/oauth/token").permitAll();
      http.csrf().disable(); //TODO 暂时关闭CSRF
      http.anonymous().disable()
            .authorizeRequests()
            .antMatchers("/oauth/token").permitAll();
    }
    @Override