Skip to content

Commit 66922d0

Browse files
committed
Move Services to CredentialProfile and remove it from Options
1 parent d004469 commit 66922d0

File tree

6 files changed

+42
-264
lines changed

6 files changed

+42
-264
lines changed

sdk/src/Core/Amazon.Runtime/CredentialManagement/AWSCredentialsFactory.cs

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -202,44 +202,17 @@ private static AWSCredentials GetAWSCredentialsInternal(
202202
switch (profileType)
203203
{
204204
case CredentialProfileType.Basic:
205-
case CredentialProfileType.BasicWithServices:
206-
case CredentialProfileType.BasicWithGlobalEndpoint:
207-
case CredentialProfileType.BasicWithServicesAndGlobalEndpoint:
208205
return string.IsNullOrEmpty(options.AwsAccountId) ? new BasicAWSCredentials(options.AccessKey, options.SecretKey) : new BasicAWSCredentials(options.AccessKey, options.SecretKey, options.AwsAccountId);
209206
case CredentialProfileType.Session:
210-
case CredentialProfileType.SessionWithServices:
211-
case CredentialProfileType.SessionWithGlobalEndpoint:
212-
case CredentialProfileType.SessionWithServicesAndGlobalEndpoint:
213207
return string.IsNullOrEmpty(options.AwsAccountId) ? new SessionAWSCredentials(options.AccessKey, options.SecretKey, options.Token) : new SessionAWSCredentials(options.AccessKey, options.SecretKey, options.Token, options.AwsAccountId); ;
214208
case CredentialProfileType.AssumeRole:
215-
case CredentialProfileType.AssumeRoleWithServices:
216-
case CredentialProfileType.AssumeRoleWithGlobalEndpoint:
217-
case CredentialProfileType.AssumeRoleWithServicesAndGlobalEndpoint:
218209
case CredentialProfileType.AssumeRoleExternal:
219-
case CredentialProfileType.AssumeRoleExternalWithServices:
220-
case CredentialProfileType.AssumeRoleExternalWithGlobalEndpoint:
221-
case CredentialProfileType.AssumeRoleExternalWithServicesAndGlobalEndpoint:
222210
case CredentialProfileType.AssumeRoleMFA:
223-
case CredentialProfileType.AssumeRoleMFAWithServices:
224-
case CredentialProfileType.AssumeRoleMFAWithGlobalEndpoint:
225-
case CredentialProfileType.AssumeRoleMFAWithServicesAndGlobalEndpoint:
226211
case CredentialProfileType.AssumeRoleExternalMFA:
227-
case CredentialProfileType.AssumeRoleExternalMFAWithServices:
228-
case CredentialProfileType.AssumeRoleExternalMFAWithGlobalEndpoint:
229-
case CredentialProfileType.AssumeRoleExternalMFAWithServicesAndGlobalEndpoint:
230212
case CredentialProfileType.AssumeRoleSessionName:
231-
case CredentialProfileType.AssumeRoleSessionNameWithServices:
232-
case CredentialProfileType.AssumeRoleSessionNameWithGlobalEndpoint:
233-
case CredentialProfileType.AssumeRoleSessionNameWithServicesAndGlobalEndpoint:
234-
case CredentialProfileType.AssumeRoleMFASessionNameWithServices:
235-
case CredentialProfileType.AssumeRoleMFASessionNameWithGlobalEndpoint:
236-
case CredentialProfileType.AssumeRoleMFASessionNameWithServicesAndGlobalEndpoint:
237213
case CredentialProfileType.AssumeRoleExternalSessionName:
238214
case CredentialProfileType.AssumeRoleMFASessionName:
239215
case CredentialProfileType.AssumeRoleExternalMFASessionName:
240-
case CredentialProfileType.AssumeRoleExternalMFASessionNameWithServices:
241-
case CredentialProfileType.AssumeRoleExternalMFASessionNameWithGlobalEndpoint:
242-
case CredentialProfileType.AssumeRoleExternalMFASessionNameWithServicesAndGlobalEndpoint:
243216
if (profileName != null)
244217
{
245218
if (profileLoopAvoidance == null)
@@ -278,13 +251,7 @@ private static AWSCredentials GetAWSCredentialsInternal(
278251
};
279252
return new AssumeRoleAWSCredentials(sourceCredentials, options.RoleArn, roleSessionName, assumeRoleOptions);
280253
case CredentialProfileType.AssumeRoleCredentialSource:
281-
case CredentialProfileType.AssumeRoleCredentialSourceWithGlobalEndpoint:
282-
case CredentialProfileType.AssumeRoleCredentialSourceWithServices:
283-
case CredentialProfileType.AssumeRoleCredentialSourceWithServicesAndGlobalEndpoint:
284254
case CredentialProfileType.AssumeRoleCredentialSourceSessionName:
285-
case CredentialProfileType.AssumeRoleCredentialSourceSessionNameWithServices:
286-
case CredentialProfileType.AssumeRoleCredentialSourceSessionNameWithGlobalEndpoint:
287-
case CredentialProfileType.AssumeRoleCredentialSourceSessionNameWithServicesAndGlobalEndpoint:
288255
// get credentials specified by credentialSource
289256
try
290257
{
@@ -304,13 +271,7 @@ private static AWSCredentials GetAWSCredentialsInternal(
304271
assumeRoleOptions = new AssumeRoleAWSCredentialsOptions();
305272
return new AssumeRoleAWSCredentials(sourceCredentials, options.RoleArn, roleSessionName, assumeRoleOptions);
306273
case CredentialProfileType.AssumeRoleWithWebIdentity:
307-
case CredentialProfileType.AssumeRoleWithWebIdentityWithServices:
308-
case CredentialProfileType.AssumeRoleWithWebIdentityWithGlobalEndpoint:
309-
case CredentialProfileType.AssumeRoleWithWebIdentityWithServicesAndGlobalEndpoint:
310274
case CredentialProfileType.AssumeRoleWithWebIdentitySessionName:
311-
case CredentialProfileType.AssumeRoleWithWebIdentitySessionNameWithServices:
312-
case CredentialProfileType.AssumeRoleWithWebIdentitySessionNameWithGlobalEndpoint:
313-
case CredentialProfileType.AssumeRoleWithWebIdentitySessionNameWithServicesAndGlobalEndpoint:
314275
return new AssumeRoleWithWebIdentityCredentials(options.WebIdentityTokenFile, options.RoleArn, options.RoleSessionName);
315276

316277
case CredentialProfileType.SSO:
@@ -329,13 +290,7 @@ private static AWSCredentials GetAWSCredentialsInternal(
329290
}
330291

331292
case CredentialProfileType.SAMLRole:
332-
case CredentialProfileType.SAMLRoleWithServices:
333-
case CredentialProfileType.SAMLRoleWithGlobalEndpoint:
334-
case CredentialProfileType.SAMLRoleWithServicesAndGlobalEndpoint:
335293
case CredentialProfileType.SAMLRoleUserIdentity:
336-
case CredentialProfileType.SAMLRoleUserIdentityWithServices:
337-
case CredentialProfileType.SAMLRoleUserIdentityWithGlobalEndpoint:
338-
case CredentialProfileType.SAMLRoleUserIdentityWithServicesAndGlobalEndpoint:
339294

340295
if (UserCrypto.IsUserCryptAvailable)
341296
{

sdk/src/Core/Amazon.Runtime/CredentialManagement/CredentialProfile.cs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,21 @@ internal Dictionary<string, Dictionary<string, string>> NestedProperties
161161
/// </summary>
162162
public string ClientAppId { get; set; }
163163

164-
public string AwsAccountId { get; set; }
165-
164+
/// <summary>
165+
/// The name of the section which contains the custom endpoints for a service or services.
166+
/// For example:
167+
/// [profile foo]
168+
/// services = bar
169+
/// [services bar]
170+
/// s3 =
171+
/// endpoint_url = https://custom-endpoint-s3:80
172+
/// ec2 =
173+
/// endpoint_url = https://custome-endpoint_ec2:80
174+
/// This will tell the SDK to look for custom endpoints in "bar" for the profile "foo.
175+
/// A single Services section can contain configurations for multiple services.
176+
/// </summary>
177+
public string Services { get; set; }
178+
166179

167180
/// <summary>
168181
/// Determines the behavior for calculating checksums for request payloads.

sdk/src/Core/Amazon.Runtime/CredentialManagement/CredentialProfileOptions.cs

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -89,24 +89,6 @@ public class CredentialProfileOptions
8989
/// Absolute path to the file on disk containing an OIDC token.
9090
/// </summary>
9191
public string WebIdentityTokenFile { get; set; }
92-
/// <summary>
93-
/// The name of the section which contains the custom endpoints for a service or services.
94-
/// For example:
95-
/// [profile foo]
96-
/// services = bar
97-
/// [services bar]
98-
/// s3 =
99-
/// endpoint_url = https://custom-endpoint-s3:80
100-
/// ec2 =
101-
/// endpoint_url = https://custome-endpoint_ec2:80
102-
/// This will tell the SDK to look for custom endpoints in "bar" for the profile "foo.
103-
/// A single Services section can contain configurations for multiple services.
104-
/// </summary>
105-
public string Services { get; set; }
106-
/// <summary>
107-
/// The global endpoint to use for a profile. Service specific endpoints will always override this value.
108-
/// </summary>
109-
public string EndpointUrl { get; set; }
11092

11193
/// <summary>
11294
/// The AWS account ID that temporary AWS credentials will be resolved for using AWS SSO.
@@ -164,8 +146,6 @@ internal bool IsEmpty
164146
string.IsNullOrEmpty(SourceProfile) &&
165147
string.IsNullOrEmpty(Token) &&
166148
string.IsNullOrEmpty(CredentialProcess) &&
167-
string.IsNullOrEmpty(Services) &&
168-
string.IsNullOrEmpty(EndpointUrl) &&
169149
string.IsNullOrEmpty(SsoAccountId) &&
170150
string.IsNullOrEmpty(SsoRegion) &&
171151
string.IsNullOrEmpty(SsoRegistrationScopes) &&
@@ -187,8 +167,6 @@ public override string ToString()
187167
"RoleSessionName=" + RoleSessionName + ", " +
188168
"SecretKey=XXXXX, " +
189169
"SourceProfile=" + SourceProfile + ", " +
190-
"EndpointUrl=" + EndpointUrl + ", " +
191-
"Services=" + Services + ", " +
192170
"Token=" + Token +
193171
", " + "UserIdentity=" + UserIdentity +
194172
", " + "CredentialProcess=" + CredentialProcess +
@@ -213,13 +191,13 @@ public override bool Equals(object obj)
213191
return false;
214192

215193
return AWSSDKUtils.AreEqual(
216-
new object[] { AccessKey, EndpointName, ExternalID, MfaSerial, RoleArn, RoleSessionName, SecretKey, SourceProfile, Token, UserIdentity, CredentialProcess, WebIdentityTokenFile, SsoAccountId, SsoRegion, SsoRegistrationScopes, SsoRoleName, SsoStartUrl, SsoSession, Services, EndpointUrl, AwsAccountId },
217-
new object[] { po.AccessKey, po.EndpointName, po.ExternalID, po.MfaSerial, po.RoleArn, po.RoleSessionName, po.SecretKey, po.SourceProfile, po.Token, po.UserIdentity, po.CredentialProcess, po.WebIdentityTokenFile, po.SsoAccountId, po.SsoRegion, po.SsoRegistrationScopes, po.SsoRoleName, po.SsoStartUrl, po.SsoSession, po.Services, po.EndpointUrl, po.AwsAccountId });
194+
new object[] { AccessKey, EndpointName, ExternalID, MfaSerial, RoleArn, RoleSessionName, SecretKey, SourceProfile, Token, UserIdentity, CredentialProcess, WebIdentityTokenFile, SsoAccountId, SsoRegion, SsoRegistrationScopes, SsoRoleName, SsoStartUrl, SsoSession, AwsAccountId },
195+
new object[] { po.AccessKey, po.EndpointName, po.ExternalID, po.MfaSerial, po.RoleArn, po.RoleSessionName, po.SecretKey, po.SourceProfile, po.Token, po.UserIdentity, po.CredentialProcess, po.WebIdentityTokenFile, po.SsoAccountId, po.SsoRegion, po.SsoRegistrationScopes, po.SsoRoleName, po.SsoStartUrl, po.SsoSession, po.AwsAccountId });
218196
}
219197

220198
public override int GetHashCode()
221199
{
222-
return Hashing.Hash(AccessKey, EndpointName, ExternalID, MfaSerial, RoleArn, RoleSessionName, SecretKey, SourceProfile, Token, UserIdentity, CredentialProcess, WebIdentityTokenFile, SsoAccountId, SsoRegion, SsoRegistrationScopes, SsoRoleName, SsoStartUrl, SsoSession, Services, EndpointUrl, AwsAccountId);
200+
return Hashing.Hash(AccessKey, EndpointName, ExternalID, MfaSerial, RoleArn, RoleSessionName, SecretKey, SourceProfile, Token, UserIdentity, CredentialProcess, WebIdentityTokenFile, SsoAccountId, SsoRegion, SsoRegistrationScopes, SsoRoleName, SsoStartUrl, SsoSession, AwsAccountId);
223201
}
224202
}
225203
}

0 commit comments

Comments
 (0)