diff --git a/.changes/next-release/feature-AWSSDKforJavav2-1cce30d.json b/.changes/next-release/feature-AWSSDKforJavav2-1cce30d.json index 60b813b41e80..3c397e773295 100644 --- a/.changes/next-release/feature-AWSSDKforJavav2-1cce30d.json +++ b/.changes/next-release/feature-AWSSDKforJavav2-1cce30d.json @@ -2,5 +2,5 @@ "type": "feature", "category": "AWS SDK for Java v2", "contributor": "", - "description": "Add CredentialDaemonCredentialsProvider, which resolves credentials from a local credential daemon over a Unix domain socket for profiles that set daemon_credential in the shared config file. Compatibility note: the provider requires Java 16 or later on Linux or macOS. On Java 8 to 15 it fails with UNSUPPORTED_PLATFORM, and a profile that runs `aws configure export-credentials` as its credential_process can be used instead." + "description": "Add CredentialDaemonCredentialsProvider, which resolves credentials from a local credential daemon over a Unix domain socket for profiles that set credential_daemon in the shared config file. Compatibility note: the provider requires Java 16 or later on Linux or macOS. On Java 8 to 15 it fails with UNSUPPORTED_PLATFORM, and a profile that runs `aws configure export-credentials` as its credential_process can be used instead." } diff --git a/core/auth/src/main/java/software/amazon/awssdk/auth/credentials/CredentialDaemonCredentialsProvider.java b/core/auth/src/main/java/software/amazon/awssdk/auth/credentials/CredentialDaemonCredentialsProvider.java index fd0b2af22dd8..c6d5114f5ea7 100644 --- a/core/auth/src/main/java/software/amazon/awssdk/auth/credentials/CredentialDaemonCredentialsProvider.java +++ b/core/auth/src/main/java/software/amazon/awssdk/auth/credentials/CredentialDaemonCredentialsProvider.java @@ -15,6 +15,7 @@ package software.amazon.awssdk.auth.credentials; +import java.nio.file.Path; import java.time.Clock; import java.time.Duration; import java.time.Instant; @@ -38,12 +39,14 @@ /** * Loads short-lived credentials from a local credential daemon over a Unix domain socket. This is used to support the - * {@code daemon_credential} setting in the shared config file. + * {@code credential_daemon} setting in the shared config file. * *
* Each fetch opens a new connection to the daemon and sends one JSON-RPC 2.0 {@code credential/get} request. The socket is * looked up again on every fetch, in this order: *
* On such a platform, an application can still use the daemon's credentials through the AWS CLI. Give it a separate profile - * that does not set {@code daemon_credential} and runs the CLI as a credential process, for example: + * that does not set {@code credential_daemon} and runs the CLI as a credential process, for example: *
* [profile daemon-via-cli] * credential_process = aws configure export-credentials --profile my-daemon-profile --format process *- * where {@code my-daemon-profile} is the profile that sets {@code daemon_credential}. + * where {@code my-daemon-profile} is the profile that sets {@code credential_daemon}. * *
* Failures are raised as {@link CredentialDaemonException}, whose {@link CredentialDaemonException#errorCode()} identifies
@@ -95,6 +98,7 @@ public final class CredentialDaemonCredentialsProvider
private final String credentialName;
private final String accountId;
private final String roleName;
+ private final Path socketPath;
private final Duration connectTimeout;
private final Duration callTimeout;
private final Boolean asyncCredentialUpdateEnabled;
@@ -116,13 +120,14 @@ private CredentialDaemonCredentialsProvider(BuilderImpl builder) {
this.accountId = builder.accountId;
this.roleName = builder.roleName;
Validate.isTrue((accountId == null) == (roleName == null), "accountId and roleName must be set together.");
+ this.socketPath = builder.socketPath;
this.connectTimeout = Validate.isPositive(builder.connectTimeout, "connectTimeout");
this.callTimeout = Validate.isPositive(builder.callTimeout, "callTimeout");
this.asyncCredentialUpdateEnabled = builder.asyncCredentialUpdateEnabled;
this.sourceChain = builder.sourceChain;
String providerName = StringUtils.isEmpty(sourceChain) ? PROVIDER_NAME : sourceChain + "," + PROVIDER_NAME;
this.request = new CredentialDaemonRequest(credentialName, accountId, roleName);
- this.client = CredentialDaemonClient.create(connectTimeout, callTimeout, providerName);
+ this.client = CredentialDaemonClient.create(socketPath, connectTimeout, callTimeout, providerName);
this.clock = builder.clock;
CachedSupplier.Builder