// Path: wechat-mp-autoconfigure/src/main/java/com/github/hippoom/wechat/mp/autoconfigure/security/web/WeChatMpWebSecurityConfigurerAdapter.java
// @RequiredArgsConstructor
// public class WeChatMpWebSecurityConfigurerAdapter extends WebSecurityConfigurerAdapter {
// 
//     @Getter
//     @Autowired
//     private WxMpService wxMpService;
// 
//     @Override
//     protected void configure(AuthenticationManagerBuilder auth)
//         throws Exception {
//     }
// 
//     @Override
//     protected void configure(HttpSecurity http) throws Exception {
// 
//         configureAuthorizeRequests(defaultHttp(http));
//     }
// 
//     /**
//      * subclass should override this to customize protected resources.
//      *
//      * @param httpSecurity see {@link HttpSecurity}
//      * @throws Exception just throw
//      */
//     protected void configureAuthorizeRequests(HttpSecurity httpSecurity) throws Exception {
//         // @formatter:off
//         httpSecurity
//             .antMatcher("/**").authorizeRequests()
//                 .antMatchers("/rel/**/me").authenticated()
//                 .anyRequest().permitAll();
//         // @formatter:on
//     }
// 
//     protected HttpSecurity defaultHttp(HttpSecurity http) throws Exception {
//         // @formatter:off
//         return http.sessionManagement().sessionCreationPolicy(IF_REQUIRED)
//             .and()
//                 .csrf().requireCsrfProtectionMatcher(requireCsrfProtectionMatcher())
//                     .csrfTokenRepository(csrfTokenRepository())
//             .and()
//                 .addFilterAfter(weChatMpOAuth2AuthenticationProcessingFilter(wxMpService),
//                     CsrfFilter.class)
//                 .exceptionHandling()
//                     .authenticationEntryPoint(restAuthenticationEntryPoint())
//             .and();
//         // @formatter:on
//     }
// 
//     /**
//      * subclass should override this to
//      * customize {@link CsrfConfigurer#requireCsrfProtectionMatcher(RequestMatcher)}.
//      *
//      * @return see {@link RequestMatcher}
//      */
//     protected RequestMatcher requireCsrfProtectionMatcher() {
//         return new AntPathRequestMatcher("/rel/**/me");
//     }
// 
//     @Bean
//     protected CsrfTokenRepository csrfTokenRepository() {
//         return CookieCsrfTokenRepository.withHttpOnlyFalse();
//     }
// 
//     @Bean
//     protected CsrfAuthenticationStrategy sessionAuthenticationStrategy() {
//         return new CsrfAuthenticationStrategy(csrfTokenRepository());
//     }
// 
// 
//     @Bean
//     protected RestAuthenticationEntryPoint restAuthenticationEntryPoint() {
//         return new RestAuthenticationEntryPoint();
//     }
// 
//     protected WeChatMpOAuth2AuthenticationProcessingFilter
//         // @formatter:off
//         weChatMpOAuth2AuthenticationProcessingFilter(WxMpService wxMpService) {
// 
//         WeChatMpOAuth2AuthenticationProcessingFilter filter =
//             new WeChatMpOAuth2AuthenticationProcessingFilter("/wechat/oauth/token");
//         filter.setWxMpService(wxMpService);
//         filter
//             .setAuthenticationSuccessHandler(new WeChatMpOAuth2AuthenticationSuccessHandler());
//         filter.setSessionAuthenticationStrategy(sessionAuthenticationStrategy());
// 
//         return filter;
//     }
//     // @formatter:on
// 
// }


import com.github.hippoom.wechat.mp.autoconfigure.security.web.WeChatMpWebSecurityConfigurerAdapter;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Configuration;
package com.github.hippoom.wechat.mp.examples.oauth2.http;


@Configuration
@RequiredArgsConstructor
// Path: wechat-mp-autoconfigure/src/main/java/com/github/hippoom/wechat/mp/autoconfigure/security/web/WeChatMpWebSecurityConfigurerAdapter.java
// @RequiredArgsConstructor
// public class WeChatMpWebSecurityConfigurerAdapter extends WebSecurityConfigurerAdapter {
// 
//     @Getter
//     @Autowired
//     private WxMpService wxMpService;
// 
//     @Override
//     protected void configure(AuthenticationManagerBuilder auth)
//         throws Exception {
//     }
// 
//     @Override
//     protected void configure(HttpSecurity http) throws Exception {
// 
//         configureAuthorizeRequests(defaultHttp(http));
//     }
// 
//     /**
//      * subclass should override this to customize protected resources.
//      *
//      * @param httpSecurity see {@link HttpSecurity}
//      * @throws Exception just throw
//      */
//     protected void configureAuthorizeRequests(HttpSecurity httpSecurity) throws Exception {
//         // @formatter:off
//         httpSecurity
//             .antMatcher("/**").authorizeRequests()
//                 .antMatchers("/rel/**/me").authenticated()
//                 .anyRequest().permitAll();
//         // @formatter:on
//     }
// 
//     protected HttpSecurity defaultHttp(HttpSecurity http) throws Exception {
//         // @formatter:off
//         return http.sessionManagement().sessionCreationPolicy(IF_REQUIRED)
//             .and()
//                 .csrf().requireCsrfProtectionMatcher(requireCsrfProtectionMatcher())
//                     .csrfTokenRepository(csrfTokenRepository())
//             .and()
//                 .addFilterAfter(weChatMpOAuth2AuthenticationProcessingFilter(wxMpService),
//                     CsrfFilter.class)
//                 .exceptionHandling()
//                     .authenticationEntryPoint(restAuthenticationEntryPoint())
//             .and();
//         // @formatter:on
//     }
// 
//     /**
//      * subclass should override this to
//      * customize {@link CsrfConfigurer#requireCsrfProtectionMatcher(RequestMatcher)}.
//      *
//      * @return see {@link RequestMatcher}
//      */
//     protected RequestMatcher requireCsrfProtectionMatcher() {
//         return new AntPathRequestMatcher("/rel/**/me");
//     }
// 
//     @Bean
//     protected CsrfTokenRepository csrfTokenRepository() {
//         return CookieCsrfTokenRepository.withHttpOnlyFalse();
//     }
// 
//     @Bean
//     protected CsrfAuthenticationStrategy sessionAuthenticationStrategy() {
//         return new CsrfAuthenticationStrategy(csrfTokenRepository());
//     }
// 
// 
//     @Bean
//     protected RestAuthenticationEntryPoint restAuthenticationEntryPoint() {
//         return new RestAuthenticationEntryPoint();
//     }
// 
//     protected WeChatMpOAuth2AuthenticationProcessingFilter
//         // @formatter:off
//         weChatMpOAuth2AuthenticationProcessingFilter(WxMpService wxMpService) {
// 
//         WeChatMpOAuth2AuthenticationProcessingFilter filter =
//             new WeChatMpOAuth2AuthenticationProcessingFilter("/wechat/oauth/token");
//         filter.setWxMpService(wxMpService);
//         filter
//             .setAuthenticationSuccessHandler(new WeChatMpOAuth2AuthenticationSuccessHandler());
//         filter.setSessionAuthenticationStrategy(sessionAuthenticationStrategy());
// 
//         return filter;
//     }
//     // @formatter:on
// 
// }


// Path: examples/oauth2/src/main/java/com/github/hippoom/wechat/mp/examples/oauth2/http/HttpSecurityConfig.java
import com.github.hippoom.wechat.mp.autoconfigure.security.web.WeChatMpWebSecurityConfigurerAdapter;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Configuration;

package com.github.hippoom.wechat.mp.examples.oauth2.http;


@Configuration
@RequiredArgsConstructor
public class HttpSecurityConfig extends WeChatMpWebSecurityConfigurerAdapter {