public static Filter general(AuthorizationCodeResourceDetails client, ResourceServerProperties resourceServerProperties, String path, OAuth2ClientContext oauth2ClientContext) { OAuth2ClientAuthenticationProcessingFilter oAuth2ClientAuthenticationFilter = new OAuth2ClientAuthenticationProcessingFilter(path){ protected void successfulAuthentication(HttpServletRequest request, HttpServletResponse response, FilterChain chain, Authentication authResult) throws IOException, ServletException { super.successfulAuthentication(request, response, chain, authResult); OAuth2AccessToken accessToken = restTemplate.getAccessToken(); log.warn(new Gson().toJson(authResult)); log.warn(new Gson().toJson(accessToken)); } }; OAuth2RestTemplate oAuth2RestTemplate = new OAuth2RestTemplate(client, oauth2ClientContext); oAuth2ClientAuthenticationFilter.setRestTemplate(oAuth2RestTemplate); UserInfoTokenServices tokenServices = new UserInfoTokenServices(resourceServerProperties.getUserInfoUri(), client.getClientId()); tokenServices.setRestTemplate(oAuth2RestTemplate); oAuth2ClientAuthenticationFilter.setTokenServices(tokenServices); return oAuth2ClientAuthenticationFilter; }
public static Filter wechat(AuthorizationCodeResourceDetails client, ResourceServerProperties resourceServerProperties, String path, OAuth2ClientContext oauth2ClientContext) { OAuth2ClientAuthenticationProcessingFilter oAuth2ClientAuthenticationFilter = new OAuth2ClientAuthenticationProcessingFilter(path); OAuth2RestTemplate oAuth2RestTemplate = new OAuth2RestTemplate(client, oauth2ClientContext); AuthorizationCodeAccessTokenProvider accessTokenProvider = new AuthorizationCodeAccessTokenProvider(); accessTokenProvider.setAuthorizationRequestEnhancer((request, resource, form, headers) -> { form.set("appid", resource.getClientId()); form.set("secret", resource.getClientSecret()); form.set("scope", "snsapi_userinfo"); form.set("response_type", "code"); form.set("#wechat_redirect", ""); }); accessTokenProvider.setMessageConverters(converters()); oAuth2RestTemplate.setAccessTokenProvider(accessTokenProvider); oAuth2RestTemplate.setRetryBadAccessTokens(true); oAuth2ClientAuthenticationFilter.setRestTemplate(oAuth2RestTemplate); UserInfoTokenServices tokenServices = new UserInfoTokenServices(resourceServerProperties.getUserInfoUri(), client.getClientId()); tokenServices.setRestTemplate(oAuth2RestTemplate); oAuth2ClientAuthenticationFilter.setTokenServices(tokenServices); return oAuth2ClientAuthenticationFilter; }
@Autowired AuthWithoutOAuthConfiguration( ResourceServerProperties resourceServerProperties, PreAuthenticationFailureFilter preAuthenticationFailureFilter ) { this.resourceServerProperties = resourceServerProperties; this.preAuthenticationFailureFilter = preAuthenticationFailureFilter; }
@Autowired AuthConfiguration( ResourceServerProperties resourceServerProperties, AuditOAuth2AuthenticationExceptionHandler auditOAuth2AuthenticationExceptionHandler, AuditOAuth2AccessDeniedHandler auditOAuth2AccessDeniedHandler, PreAuthenticationFailureFilter preAuthenticationFailureFilter, OAuth2ExtraValidationFilter oAuth2ExtraValidationFilter ) { this.resourceServerProperties = resourceServerProperties; this.auditOAuth2AuthenticationExceptionHandler = auditOAuth2AuthenticationExceptionHandler; this.auditOAuth2AccessDeniedHandler = auditOAuth2AccessDeniedHandler; this.preAuthenticationFailureFilter = preAuthenticationFailureFilter; this.oAuth2ExtraValidationFilter = oAuth2ExtraValidationFilter; }
@Bean public ResourceServerProperties resourceServerProperties() { return new ResourceServerProperties(this.credentials.getClientId(), this.credentials.getClientSecret()); }
protected CustomResourceServer(ResourceServerProperties config) { this.config = config; }
@Bean @ConfigurationProperties("facebook.resource") public ResourceServerProperties facebookResource() { return new ResourceServerProperties(); }
@Bean @ConfigurationProperties("google.resource") public ResourceServerProperties googleResource() { return new ResourceServerProperties(); }
@Bean public ResourceServerProperties resourceServerProperties(){ return new ResourceServerProperties(); }
public ResourceServerProperties getResource() { return resource; }
public ResourceServerConfiguration(ResourceServerProperties resource, CustomOAuth2AuthenticationManager customOAuth2AuthenticationManager) { this.resource = resource; this.customOAuth2AuthenticationManager = customOAuth2AuthenticationManager; }
@Bean @ConfigurationProperties("eve.resource") protected ResourceServerProperties eveResource() { return new ResourceServerProperties(); }
@Bean public ResourceServerProperties resourceServerProperties() { return new ResourceServerProperties(); }