use of org.springframework.boot.autoconfigure.security.oauth2.resource.UserInfoTokenServices in project spring-boot-quick by vector4wang.
the class WebSecurityConfig method sso.
private Filter sso() {
OAuth2ClientAuthenticationProcessingFilter githubFilter = new OAuth2ClientAuthenticationProcessingFilter("/login/github");
OAuth2RestTemplate githubTemplate = new OAuth2RestTemplate(github(), oauth2ClientContext);
githubFilter.setRestTemplate(githubTemplate);
githubFilter.setTokenServices(new UserInfoTokenServices(githubResource().getUserInfoUri(), github().getClientId()));
return githubFilter;
}
use of org.springframework.boot.autoconfigure.security.oauth2.resource.UserInfoTokenServices in project spring-cloud-security by spring-cloud.
the class ResourceServerTokenRelayAutoConfigurationTests method clientConfigured.
@Test
public void clientConfigured() throws Exception {
this.context = new SpringApplicationBuilder(ClientConfiguration.class).properties("spring.config.name=test", "server.port=0", "security.oauth2.resource.userInfoUri:http://example.com", "security.oauth2.client.clientId=foo").run();
RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(new MockHttpServletRequest()));
OAuth2ClientContext client = this.context.getBean(OAuth2ClientContext.class);
assertNull(client.getAccessToken());
UserInfoTokenServices services = context.getBean(UserInfoTokenServices.class);
OAuth2RestTemplate template = (OAuth2RestTemplate) ReflectionTestUtils.getField(services, "restTemplate");
MockRestServiceServer server = MockRestServiceServer.createServer(template);
server.expect(requestTo("http://example.com")).andRespond(withSuccess("{\"id\":\"user\"}", MediaType.APPLICATION_JSON));
services.loadAuthentication("FOO");
assertEquals("FOO", client.getAccessToken().getValue());
server.verify();
}
Aggregations