View Javadoc
1   package org.oxerr.spring.security.wechat.samples.helloworld;
2   
3   import org.oxerr.spring.security.wechat.config.annotation.web.configurers.WeChatLoginConfigurer;
4   import org.oxerr.spring.security.wechat.core.userdetails.WeChatUserDetailsService;
5   import org.oxerr.spring.security.wechat.web.authentication.WeChatService;
6   import org.springframework.beans.factory.annotation.Autowired;
7   import org.springframework.context.annotation.Configuration;
8   import org.springframework.security.config.annotation.web.builders.HttpSecurity;
9   import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
10  import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
11  
12  @EnableWebSecurity
13  public class SecurityConfiguration {
14  
15  	@Configuration
16  	public static class FormLoginWebSecurityConfigurerAdapter extends WebSecurityConfigurerAdapter {
17  
18  		@Autowired
19  		private WeChatService weChatService;
20  
21  		@Autowired
22  		private WeChatUserDetailsService weChatUserDetailsService;
23  
24  		@Override
25  		protected void configure(HttpSecurity http) throws Exception {
26  			http
27  				.authorizeRequests()
28  					.anyRequest().permitAll()
29  					.and()
30  				.formLogin().permitAll()
31  					.and()
32  				.apply(new WeChatLoginConfigurer<>(weChatService, weChatUserDetailsService)).loginProcessingUrl("/login").permitAll();
33  		}
34  
35  	}
36  
37  }