davsclaus opened a new pull request, #31025: URL: https://github.com/apache/camel/pull/31025
JIRA: https://issues.apache.org/jira/browse/CAMEL-27667 ## What was wrong `AwsClientBuilderUtil.resolveCredentialsProvider` in `camel-aws-common` (used by the client factories of almost all AWS components) returned `null` when `useSessionCredentials=true` but the `accessKey`, `secretKey` or `sessionToken` was missing. The client builder then got no credentials provider, and the AWS SDK used its default credentials chain (environment variables, system properties, `~/.aws` profiles, instance or container role) without any message. With only the `sessionToken` missing, the keys were used as static credentials without the token. The component-level check in `createEndpoint` is skipped as soon as `useSessionCredentials=true`, so nothing caught it. The static credentials path had the same fall-through: with only one of `accessKey` / `secretKey` set (or one of them an empty string, which the `== null` check of the components does not catch), the default chain was used. ## What changed - `useSessionCredentials=true` with a missing (or empty) `accessKey`, `secretKey` or `sessionToken` fails with an `IllegalArgumentException` that names the missing option(s), e.g. `useSessionCredentials is set to true, but sessionToken is not set: accessKey, secretKey and sessionToken must be specified`. - Only one of `accessKey` / `secretKey` set fails with `accessKey is set, but secretKey is not set: both accessKey and secretKey must be specified` (or the reverse). - Unchanged: no credentials option at all uses the SDK default chain (documented behaviour), `useDefaultCredentialsProvider` and `useProfileCredentialsProvider` keep their behaviour and their priority. - `resolveCredentialsProvider` is now package-private so it can be tested directly. ## Not changed (own credentials logic, not through the helper) These build clients with their own copy of the credentials logic; listed for reference, not changed here: - `camel-aws2-s3` `AWS2S3Producer.getOrCreatePresigner()`: with `useSessionCredentials=true` and missing keys it fails in the AWS SDK (`AwsSessionCredentials.create` rejects null), so it does not fall back silently. - `camel-aws2-kinesis` `KclKinesis2Consumer`: the DynamoDB and CloudWatch clients of the KCL consumer pick session/static/profile credentials from the keys, ignoring the `use*` flags; the Kinesis client of the same consumer goes through the helper, so the new check applies first. - `camel-aws-secrets-manager` `SecretsManagerPropertiesFunction`, `vault/CloudTrailReloadTriggerTask` and `camel-aws-parameter-store` `ParameterStorePropertiesFunction`: these use the `camel.vault.aws.*` configuration, which has no session credentials mode. - `camel-aws2-transcribe` `Transcribe2ComponentVerifierExtension`: static credentials only. ## Tests - New `AwsClientBuilderUtilCredentialsTest` in `camel-aws-common` (10 tests): session credentials used, missing keys, missing session token, empty secret key, `buildClient`/`buildAsyncClient` failing, static credentials, only one key set (both ways), no credentials -> SDK default chain, default/profile provider still take precedence. 6 of them fail before the fix (the 4 that check unchanged behaviour pass), all pass after. - `ECS2ClientFactoryTest` in `camel-aws2-ecs`: 3 new tests through `ECS2ClientFactory` (session credentials, missing session token, missing keys). - Unit tests of `camel-aws2-ecs`, `camel-aws-security-hub`, `camel-aws2-sqs` and `camel-aws2-s3` pass. ## Docs Upgrade guide 4.24: new subsection `camel-aws - incomplete session or static credentials fail when the client is created`. No generated files change. _Claude Code on behalf of Claus Ibsen_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
