Problem with GCP Secret Manager and Spring Boot app
See original GitHub issueSpring Boot (2.5.7) has problem to access password from the GCP Secret Manager using spring-cloud-gcp-starter-secretmanager
ver 2.0.7 throwing error
AnnotationConfigApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'defaultFeignClientConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [com.google.protobuf.ByteString$LiteralByteString] to type [java.lang.String]
for a passsword declared in the application.properties as
webservices.security.password=${sm://my-password}
when I will replace it with regular string or even env variable it will work fine.
Failing part of the code looks like:
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.cloud.client.loadbalancer.LoadBalancedRetryFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.retry.backoff.BackOffPolicy;
import org.springframework.retry.backoff.ExponentialBackOffPolicy;
import feign.Retryer;
import feign.auth.BasicAuthRequestInterceptor;
import feign.codec.ErrorDecoder;
/**
* Default feign client configuration. Includes retry policies, basic auth user name and password, and HTTP status decoder.
* @author Greg Meyer
* @since 6.0
*/
public class DefaultFeignClientConfiguration
{
@Value("${webservices.retry.backoff.multiplier:3}")
protected double backoffMultiplier;
@Value("${webservices.retry.backoff.initialBackoffInterval:100}")
protected long initialBackoffInterval;
@Value("${webservices.retry.backoff.maxInterval:20000}")
protected long maxInterval;
@Value("${webservices.security.basic.user.name:}")
protected String user;
@Value("${webservices.security.basic.user.password:}")
protected String pass;
/**
* Creates an instance of the a the default HTTP status translator.
* @return An instance of the a the default HTTP status translator
*/
@Bean
public ErrorDecoder feignClientErrorDecoder()
{
return new DefaultErrorDecoder();
}
/**
* Creates an instance of BasicAuth interceptor configured with a username and password. This bean is only created if the
* "webservices.security.basic.user.name" property is set.
* @return An instance of BasicAuth interceptor configured with a username and password
*/
@Bean
@ConditionalOnProperty(name="webservices.security.basic.user.name", matchIfMissing=false)
public BasicAuthRequestInterceptor basicAuthRequestInterceptor()
{
return new BasicAuthRequestInterceptor(user, pass);
}
/**
* Creates an instance of a back off policy used in conjuntion with the retry policy.
* @return An instance of a back off policy
*/
@Bean
public LoadBalancedRetryFactory backOffPolciyFactory()
{
return new LoadBalancedRetryFactory()
{
@Override
public BackOffPolicy createBackOffPolicy(String service)
{
final ExponentialBackOffPolicy backoffPolicy = new ExponentialBackOffPolicy();
backoffPolicy.setMultiplier(backoffMultiplier);
backoffPolicy.setInitialInterval(initialBackoffInterval);
backoffPolicy.setMaxInterval(maxInterval);
return backoffPolicy;
}
};
}
/**
* Creates a default http retry policy.
* @return A default http retry policy.
*/
@Bean
public Retryer retryer()
{
/*
* Default retryer config
*/
return new Retryer.Default(200, 1000, 5);
}
}
Any thoughts?
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
Problem with GCP Secret Manager and Spring Boot app
Spring Boot (2.5.9) has problem to access password from the GCP Secret Manager using spring-cloud-gcp-starter-secretmanager ver 2.0.8 ...
Read more >Secret Management - Spring Boot on GCP
Secret Manager is a secure and convenient storage system for API keys, passwords, certificates, and other sensitive data. Secret Manager provides a central ......
Read more >Retrieving Credentials/Secrets from Secret Manager with ...
In this codelab, you will build simple Spring Boot microservices and retrieve secrets / configuration values stored in Secret Manager.
Read more >don't get value from it with Spring Boot-Springboot
Coding example for the question Google Secret Manager: don't get value from it with Spring Boot-Springboot.
Read more >Spring Cloud GCP
Configure your app with Spring Cloud Config, backed up by the Google Runtime Configuration API. Consume and produce Google Cloud Storage data via...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@RamonaMaria Could you open a new issue, and provide a minimal reproducible issue?
Registering custom converters at the correct phase will likely work. This is what the converters should look like.