[英]Problems implementing TokenProvider for CloudFoundry Java CLI
I am developing a microservice that is responsible for starting other microservices running on CloudFoundry.我正在开发一个微服务,负责启动在 CloudFoundry 上运行的其他微服务。 Therefore I make use of the cf-java-client ( https://github.com/cloudfoundry/cf-java-client ).
因此我使用了 cf-java-client ( https://github.com/cloudfoundry/cf-java-client )。 In our environment we have a special mechanism for authenticating machine users on CloudFoundry: I have to give a client id and secret to a certain endpoint, that returns an authorization code.
在我们的环境中,我们有一种特殊的机制来验证 CloudFoundry 上的机器用户:我必须给某个端点提供一个客户端 ID 和秘密,它会返回一个授权码。 With this code I can create temporary credentials for CloudFoundry (which live only 60 min).
使用此代码,我可以为 CloudFoundry 创建临时凭据(仅存活 60 分钟)。 So far I implemented this behaviour the following:
到目前为止,我实现了以下行为:
@Bean
PasswordGrantTokenProvider tokenProvider() {
final Map<String, String> temporaryCredentialsMap =
getTemporaryCredentials(clientId, clientSecret);
return PasswordGrantTokenProvider.builder()
.username(temporaryCredentialsMap.get("username"))
.password(temporaryCredentialsMap.get("password"))
.build();
}
My problem is now that, when the credentials expire, I get a HTTP 401 bad credentials.我现在的问题是,当凭据过期时,我得到 HTTP 401 错误凭据。 I was thinking of recreating the bean above.
我正在考虑重新创建上面的 bean。 Is this possible?
这可能吗? Or any other ideas?
还是有其他想法?
I solved this by changing the scope of all cf related beans to prototype scopes and requesting a new bean from the context to refresh credentials.我通过将所有 cf 相关 bean 的 scope 更改为原型范围并从上下文请求新 bean 来刷新凭据来解决此问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.