| | |
| | | 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; |
| | |
| | | .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 |