我稍微更新的春天雲服務爲例,說明我有一個問題: https://github.com/spring-cloud-services-samples/greeting/compare/master...timtebeek:masterUserInfoRestTemplateFactory安裝失敗ResourceServerConfigurerAdapter和兩個彈簧雲服務起動器
上述改變我後使用:
spring-cloud-services-starter-config-client:1.5.0.RELEASE
spring-cloud-services-starter-service-registry:1.5.0.RELEASE
spring-cloud-starter-oauth2:2.0.14.RELEASE
我還添加了一個最小的ResourceServerConfigurerAdapter
@Configuration
@EnableResourceServer
public class ResourceServerConfig extends ResourceServerConfigurerAdapter {
@Override
public void configure(final HttpSecurity http) throws Exception {
http.authorizeRequests().anyRequest().authenticated();
}
@Override
public void configure(final ResourceServerSecurityConfigurer resources) {
resources.resourceId("greeter");
}
}
和裸最低配置設置:
security: oauth2: resource: jwt: key-uri: https://example.com/oauth/token_key
這些變化我的應用程序無法在PCF-DEV部署;我沒有嘗試過PCF,但期望結果是相似的。下面是錯誤消息我得到:
Method userInfoRestTemplateFactory in org.springframework.boot.autoconfigure.security.oauth2.resource.ResourceServerTokenServicesConfiguration required a single bean, but 2 were found: - eurekaOAuth2ResourceDetails: defined by method 'eurekaOAuth2ResourceDetails' in class path resource [io/pivotal/spring/cloud/service/eureka/EurekaOAuth2AutoConfiguration.class] - configClientOAuth2ResourceDetails: defined by method 'configClientOAuth2ResourceDetails' in io.pivotal.spring.cloud.service.config.ConfigClientOAuth2BootstrapConfiguration Action: Consider marking one of the beans as @Primary, updating the consumer to accept multiple beans, or using @Qualifier to identify the bean that should be consumed
所以它試圖用什麼應該是完全獨立的OAuth2ProtectedResourceDetails
從春季雲服務起動器設置我的應用程序的安全性;我希望它只使用外部JWT密鑰。
任何人都可以幫助我如何使用配置和發現服務同時使用外部JWT令牌進行身份驗證設置嗎?
其實,只有將父母改回1.5.4纔夠好; Dalston.SR4正常工作。非常感謝! – Tim
或者,如果您傾向於:'op.spring.platform:platform-bom:Brussels-SR3'作爲父項。 – Tim
關鍵團隊正在研究新版本的'spring-boot-starter-parent'。一旦這些可用,我會回答這個問題與相應的細節。 – Tim