Andrea Cosentino created CAMEL-24468:
----------------------------------------

             Summary: camel-ibm-secrets-manager: properties function credential 
check is inverted, breaking the environment-variable configuration path
                 Key: CAMEL-24468
                 URL: https://issues.apache.org/jira/browse/CAMEL-24468
             Project: Camel
          Issue Type: Bug
            Reporter: Andrea Cosentino
            Assignee: Andrea Cosentino
             Fix For: 4.23.0


h3. Problem

{{IBMSecretsManagerPropertiesFunction.doStart()}} inverts its credential check:
{code:java}
String token = System.getenv(CAMEL_VAULT_IBM_TOKEN_ENV);
String serviceUrl = System.getenv(CAMEL_VAULT_IBM_SERVICE_URL_ENV);
if (ObjectHelper.isEmpty(token) && ObjectHelper.isEmpty(serviceUrl)) {
    // fall back to vault config, then build the client
} else {
    throw new RuntimeCamelException(
        "Using the IBM Secrets Manager Properties Function requires setting IBM 
Credentials and service url ...");
}
{code}
The client is only built when *both* env vars are empty. So when a user sets 
the documented {{CAMEL_VAULT_IBM_TOKEN}} / {{CAMEL_VAULT_IBM_SERVICE_URL}} 
environment variables (the first configuration method described in the class 
Javadoc, and the norm in containers/Kubernetes), the condition is false, 
control goes to the else, and CamelContext startup fails with a message telling 
the user to set credentials they already set. The environment-variable 
configuration path is therefore unusable; only 
application.properties/vault-config works.

h3. Fix

Use the same shape as the AWS/Google secrets-manager properties functions: read 
the env vars; if both are empty fall back to the vault configuration; then 
build the client when a token and service url are available (from either 
source) and only throw when neither provides them.

Affects main (4.23.0-SNAPSHOT).



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to