我目前正在使用OAuth2-Authentication开发Spring Boot-Application.我有一个本地OAuth2-Server,在我使用Spring Boot的UserDetails和UserService 发布本地数据库的用户名和密码时,我会收到一个令牌,我的情况是http:// localhost:8080/v1/oauth/token.一切都很好,很好.
但现在我想通过Facebook社交登录来增强我的程序,并希望登录到我的本地OAuth2-Server或使用外部Facebook-Server.我查看了Spring Boot示例https://spring.io/guides/tutorials/spring-boot-oauth2/,并调整了SSO-Filter的想法.现在我可以使用我的Facebook客户端和密码ID登录,但我无法访问我受限制的localhost-站点.
我想要的是Facebook-Token"行为"与本地生成的令牌相同,例如作为我本地令牌存储的一部分.我检查了几个教程和其他Stackoverflow问题,但没有运气.以下是我到目前为止使用的自定义Authorization-Server,我认为我仍然缺少一些非常基本的东西来获取外部Facebook-和内部localhost-Server之间的链接:
@Configuration
public class OAuth2ServerConfiguration {
private static final String SERVER_RESOURCE_ID = "oauth2-server";
@Autowired
private TokenStore tokenStore;
@Bean
public TokenStore tokenStore() {
return new InMemoryTokenStore();
}
protected class ClientResources {
@NestedConfigurationProperty
private AuthorizationCodeResourceDetails client = new AuthorizationCodeResourceDetails();
@NestedConfigurationProperty
private ResourceServerProperties resource = new ResourceServerProperties();
public AuthorizationCodeResourceDetails getClient() {
return client;
}
public ResourceServerProperties getResource() {
return resource;
}
}
@Configuration
@EnableResourceServer
@EnableOAuth2Client
protected class ResourceServerConfiguration extends ResourceServerConfigurerAdapter {
@Value("${pia.requireauth}") …Run Code Online (Sandbox Code Playgroud)