org.springframework.boot.autoconfigure.security.oauth2.resource.ResourceServerProperties Java Examples

The following examples show how to use org.springframework.boot.autoconfigure.security.oauth2.resource.ResourceServerProperties. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OAuth2Util.java    From DAFramework with MIT License 6 votes vote down vote up
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;
}
 
Example #2
Source File: OAuth2Util.java    From DAFramework with MIT License 6 votes vote down vote up
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;
}
 
Example #3
Source File: OAuth2SecurityConfiguration.java    From flair-registry with Apache License 2.0 4 votes vote down vote up
public OAuth2SecurityConfiguration(ResourceServerProperties resourceServerProperties) {
    this.resourceServerProperties = resourceServerProperties;
}
 
Example #4
Source File: OAuth2TokenServicesConfiguration.java    From okta-jhipster-microservices-oauth-example with Apache License 2.0 4 votes vote down vote up
public OAuth2TokenServicesConfiguration(ResourceServerProperties resourceServerProperties) {
	this.resourceServerProperties = resourceServerProperties;
}
 
Example #5
Source File: OAuth2TokenServicesConfiguration.java    From okta-jhipster-microservices-oauth-example with Apache License 2.0 4 votes vote down vote up
public OAuth2TokenServicesConfiguration(ResourceServerProperties resourceServerProperties) {
	this.resourceServerProperties = resourceServerProperties;
}
 
Example #6
Source File: SecurityConfigurer.java    From spring-oauth2-keycloak-connector with Apache License 2.0 4 votes vote down vote up
public SecurityConfigurer(ResourceServerProperties resourceServerProperties, SecurityProperties securityProperties) {
  this.resourceServerProperties = resourceServerProperties;
  this.securityProperties = securityProperties;
}
 
Example #7
Source File: OAuth2AutoConfiguration.java    From spring-security-oauth2-boot with Apache License 2.0 4 votes vote down vote up
@Bean
public ResourceServerProperties resourceServerProperties() {
	return new ResourceServerProperties(this.credentials.getClientId(), this.credentials.getClientSecret());
}
 
Example #8
Source File: OAuth2AutoConfigurationTests.java    From spring-security-oauth2-boot with Apache License 2.0 4 votes vote down vote up
protected CustomResourceServer(ResourceServerProperties config) {
	this.config = config;
}
 
Example #9
Source File: SpringSecurityConfiguration.java    From crnk-example with Apache License 2.0 4 votes vote down vote up
public ResourceServerProperties getResource() {
	return resource;
}
 
Example #10
Source File: SecurityConfig.java    From springboot-security-wechat with Apache License 2.0 4 votes vote down vote up
public ResourceServerProperties getResource() {
    return resource;
}
 
Example #11
Source File: SecurityConfig.java    From movie-db-java-on-azure with MIT License 4 votes vote down vote up
@Bean
@ConfigurationProperties("facebook.resource")
public ResourceServerProperties facebookResource() {
    return new ResourceServerProperties();
}
 
Example #12
Source File: OAuth2ClientResources.java    From DAFramework with MIT License 4 votes vote down vote up
public ResourceServerProperties getResource() {
	return resource;
}
 
Example #13
Source File: WebSecurityConfig.java    From mojito with Apache License 2.0 4 votes vote down vote up
@Bean
@ConditionalOnProperty(value = "l10n.security.oauth2.enabled", havingValue = "true")
@ConfigurationProperties("l10n.security.oauth2.resource")
public ResourceServerProperties oauth2Resource() {
    return new ResourceServerProperties();
}