我正在使用 Spring Cloud OAuth,我使用来自https://github.com/spring-cloud-samples/sso/的官方示例和 GitLab ( https://about.gitlab.com/ ) 作为 OAuth 提供者。
问题是 GitLab 发送一个类型为“bearer”的令牌,Spring Cloud SSO 检索令牌并发送一个 Header,
Authorization bearer xxxxxxx
根据它只接受
Authorization Bearer xxxxxxx
.
这可能是 GitLab 服务器中的一个错误,但有什么方法可以解决 Spring Cloud SSO 的这个问题。
更新 19.03:
这是我在 SpringCloud-sample 的 SsoApplication.java 中尝试过的。
@Autowired
private OAuth2RestTemplate oAuth2RestTemplate;
@PostConstruct
private void modifyOAuthRestTemplate() {
this.oAuth2RestTemplate.setAuthenticator(new OAuth2RequestAuthenticator() { // this line gets called
@Override
public void authenticate(OAuth2ProtectedResourceDetails resource, OAuth2ClientContext clientContext, ClientHttpRequest request) {
// this line is never called
}
});
}
而不是新注入的 OAuth2ProtectedResourceDetails ,而是调用“原始”的。每次我尝试在示例应用程序中进行身份验证时