Skip to content

Commit 91ad8ec

Browse files
committed
Merge branch 'feature/master/a1a78346-2a82-43fa-baba-807d38332305' into staging/98198af2-4dda-4967-85e1-adac8d2c7d65
2 parents b979024 + 0d8b66c commit 91ad8ec

File tree

29 files changed

+3005
-4
lines changed

29 files changed

+3005
-4
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"type": "feature",
3+
"category": "AWS Signin",
4+
"contributor": "",
5+
"description": "Add the LoginCredentialsProvider which allows use of AWS credentials vended by AWS Sign-In that correspond to an AWS Console session. AWS Sign-In credentials will be used automatically by the Credential resolution chain when `login_session` is set in the profile."
6+
}

aws-sdk-java/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<parent>
1818
<groupId>software.amazon.awssdk</groupId>
1919
<artifactId>aws-sdk-java-pom</artifactId>
20-
<version>2.39.0</version>
20+
<version>2.39.0-SNAPSHOT</version>
2121
<relativePath>../pom.xml</relativePath>
2222
</parent>
2323
<artifactId>aws-sdk-java</artifactId>

bom/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<parent>
1818
<groupId>software.amazon.awssdk</groupId>
1919
<artifactId>aws-sdk-java-pom</artifactId>
20-
<version>2.39.0</version>
20+
<version>2.39.0-SNAPSHOT</version>
2121
<relativePath>../pom.xml</relativePath>
2222
</parent>
2323
<artifactId>bom</artifactId>

core/auth/src/main/java/software/amazon/awssdk/auth/credentials/internal/ProfileCredentialsUtils.java

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ public final class ProfileCredentialsUtils {
5757
"software.amazon.awssdk.services.sts.internal.StsProfileCredentialsProviderFactory";
5858
private static final String SSO_PROFILE_CREDENTIALS_PROVIDER_FACTORY =
5959
"software.amazon.awssdk.services.sso.auth.SsoProfileCredentialsProviderFactory";
60+
private static final String LOGIN_PROFILE_CREDENTIALS_PROVIDER_FACTORY =
61+
"software.amazon.awssdk.services.signin.auth.LoginProfileCredentialsProviderFactory";
6062

6163
/**
6264
* The profile file containing {@code profile}.
@@ -144,6 +146,10 @@ private Optional<CredentialsWithFeatureId> credentialsProviderWithFeatureID(Set<
144146
}
145147
}
146148

149+
if (properties.containsKey(ProfileProperty.LOGIN_SESSION)) {
150+
return Optional.of(loginProfileCredentialsProvider());
151+
}
152+
147153
if (properties.containsKey(ProfileProperty.CREDENTIAL_PROCESS)) {
148154
return Optional.of(credentialProcessCredentialsProvider());
149155
}
@@ -243,6 +249,20 @@ private boolean isLegacySsoConfiguration() {
243249
return !properties.containsKey(ProfileSection.SSO_SESSION.getPropertyKeyName());
244250
}
245251

252+
/**
253+
* Create the SSO credentials provider based on the related profile properties.
254+
*/
255+
private CredentialsWithFeatureId loginProfileCredentialsProvider() {
256+
AwsCredentialsProvider provider = loginCredentialsProviderFactory().create(
257+
ProfileProviderCredentialsContext.builder()
258+
.profile(profile)
259+
.profileFile(profileFile)
260+
.sourceChain(BusinessMetricFeatureId.CREDENTIALS_PROFILE_LOGIN.value())
261+
.build());
262+
263+
return new CredentialsWithFeatureId(provider, BusinessMetricFeatureId.CREDENTIALS_PROFILE_LOGIN.value());
264+
}
265+
246266
private CredentialsWithFeatureId roleAndWebIdentityTokenProfileCredentialsProvider() {
247267
requireProperties(ProfileProperty.ROLE_ARN, ProfileProperty.WEB_IDENTITY_TOKEN_FILE);
248268

@@ -418,4 +438,17 @@ private ProfileCredentialsProviderFactory ssoCredentialsProviderFactory() {
418438
throw new IllegalStateException("Failed to create the '" + name + "' profile credentials provider.", e);
419439
}
420440
}
441+
442+
private ProfileCredentialsProviderFactory loginCredentialsProviderFactory() {
443+
try {
444+
Class<?> loginProfileCredentialsProviderFactory =
445+
ClassLoaderHelper.loadClass(LOGIN_PROFILE_CREDENTIALS_PROVIDER_FACTORY, getClass());
446+
return (ProfileCredentialsProviderFactory) loginProfileCredentialsProviderFactory.getConstructor().newInstance();
447+
} catch (ClassNotFoundException e) {
448+
throw new IllegalStateException("To use login_session property in the '" + name + "' profile, the 'signin' service "
449+
+ "module must be on the class path.", e);
450+
} catch (NoSuchMethodException | InvocationTargetException | InstantiationException | IllegalAccessException e) {
451+
throw new IllegalStateException("Failed to create the '" + name + "' profile credentials provider.", e);
452+
}
453+
}
421454
}

core/profiles/src/main/java/software/amazon/awssdk/profiles/ProfileProperty.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,11 @@ public final class ProfileProperty {
201201
*/
202202
public static final String SIGV4A_SIGNING_REGION_SET = "sigv4a_signing_region_set";
203203

204+
/**
205+
* Property name for login session used with AWS Login/Sign-In Credentials.
206+
*/
207+
public static final String LOGIN_SESSION = "login_session";
208+
204209
private ProfileProperty() {
205210
}
206211
}

core/sdk-core/src/main/java/software/amazon/awssdk/core/useragent/BusinessMetricFeatureId.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ public enum BusinessMetricFeatureId {
7575
CREDENTIALS_PROCESS("w"),
7676
CREDENTIALS_HTTP("z"),
7777
CREDENTIALS_IMDS("0"),
78+
CREDENTIALS_PROFILE_LOGIN("AC"),
79+
CREDENTIALS_LOGIN("AD"),
7880
UNKNOWN("Unknown");
7981

8082
private static final Map<String, BusinessMetricFeatureId> VALUE_MAP =

feature.metadata

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"trebuchetFeatureArn":"arn:aws:trebuchet:::feature:v2:a1a78346-2a82-43fa-baba-807d38332305","c2jModelsRevision":56,"messageId":1,"serviceId":"Signin","serviceModule":"signin","isNewService":false}

services/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<parent>
1818
<groupId>software.amazon.awssdk</groupId>
1919
<artifactId>aws-sdk-java-pom</artifactId>
20-
<version>2.39.0</version>
20+
<version>2.39.0-SNAPSHOT</version>
2121
</parent>
2222
<artifactId>services</artifactId>
2323
<name>AWS Java SDK :: Services</name>

services/signin/pom.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<parent>
1818
<groupId>software.amazon.awssdk</groupId>
1919
<artifactId>services</artifactId>
20-
<version>2.39.0</version>
20+
<version>2.39.0-SNAPSHOT</version>
2121
</parent>
2222
<artifactId>signin</artifactId>
2323
<name>AWS Java SDK :: Services :: Signin</name>
@@ -56,5 +56,10 @@
5656
<artifactId>http-auth-aws</artifactId>
5757
<version>${awsjavasdk.version}</version>
5858
</dependency>
59+
<dependency>
60+
<groupId>software.amazon.awssdk</groupId>
61+
<artifactId>profiles</artifactId>
62+
<version>${awsjavasdk.version}</version>
63+
</dependency>
5964
</dependencies>
6065
</project>

0 commit comments

Comments
 (0)