Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SSO registration scopes to SSOAWSCredentialsOptions #3133

Merged
merged 1 commit into from
Jan 8, 2024

Conversation

aberus
Copy link
Contributor

@aberus aberus commented Dec 15, 2023

This adds IList<string> Scopes to SSOAWSCredentialsOptions parsing them from CredentialProfileOptions.SsoRegistrationScopes.

Description

There is currently no way to know if a SSO profile has been set up with sso_registration_scopes when using CredentialProfile.GetAWSCredentials.

Motivation and Context

This change is for a better user experience within the AWS Toolkit for Visual Studio (aws/aws-toolkit-visual-studio#377) and AWS Tools for PowerShell (when using a combination of Get-AWSCredential & Register-SSOOIDCClient cmdlets).

Testing

Create sample config file and run Program.cs file, program should printout sso:account:access

config file:

[profile my-dev-profile]
sso_session = my-sso
sso_account_id = 123456789011
sso_role_name = readOnly
region = us-west-2
output = json

[sso-session my-sso]
sso_region = us-east-1
sso_start_url = https://my-sso-portal.awsapps.com/start
sso_registration_scopes = sso:account:access

Program.cs file:

using Amazon.Runtime.CredentialManagement;

if (new CredentialProfileStoreChain(null).TryGetProfile("test", out CredentialProfile profile))
{
  var creadentail = profile.GetAWSCredentials(profile.CredentialProfileStore) as Amazon.Runtime.SSOAWSCredentials;

  Console.WriteLine(string.Join("\t", creadentail?.Options?.Scopes));
}

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My code follows the code style of this project
  • My change requires a change to the documentation
  • I have updated the documentation accordingly
  • I have read the README document
  • I have added tests to cover my changes
  • All new and existing tests passed

License

  • I confirm that this pull request can be released under the Apache 2 license

@dscpinheiro dscpinheiro changed the base branch from main to main-staging December 15, 2023 21:28
@afroz429
Copy link
Contributor

Thanks for the PR. I am working on testing this change. Will get back to you once done.

Copy link
Contributor

@peterrsongg peterrsongg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tested the code and it works good on my end. Approving

@afroz429 afroz429 merged commit 5f5d2d2 into aws:main-staging Jan 8, 2024
@aberus aberus deleted the sso-credentials-patch branch January 8, 2024 21:01
@afroz429
Copy link
Contributor

afroz429 commented Jan 9, 2024

Thanks for the PR. Today's release (3.7.722.0) has this feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants