-
Notifications
You must be signed in to change notification settings - Fork 196
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 Support for SSO #1051
Add Support for SSO #1051
Conversation
This commit adds support for the SSO credential provider, which enables the aws-config to support using SSO when specified in `~/.aws/config`.
A new doc preview is ready to view. |
A new generated diff is ready to view.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks great! I just have some questions and some minor fixes.
- Improve error messages - zeroize token - add track_caller to improve test failure error messages
Co-authored-by: John DiSanti <jdisanti@amazon.com>
A new doc preview is ready to view. |
A new doc preview is ready to view. |
A new generated diff is ready to view. |
A new doc preview is ready to view. |
A new generated diff is ready to view.
|
A new generated diff is ready to view. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome!
Excited to see this passed! This will certainly help in building applications which leverage SSO. I'm trying to find out how the AWS CLI does
My goal is naturally that for a given AWS utility, I want it to work, whether credentials are coming from environment variables, from the credentials file(s), from an SSO configuration, or from the EC2 metadata server. Does anyone know enough to point me to where |
I ran
this code was hard to track down! I eventually found it here: https://fossies.org/linux/www/aws-cli-2.4.10.tar.gz/ |
After loads of reverse engineering and dropping debug points, it's all handled in the Register your ClientFirst, call Start Device AuthorizationNext, call You're now ready to launch the browser. Launch the BrowserLaunch your browser to Create and Obtain the TokenIn a loop, and respectfully, attempt to You'll need to match on error responses, because Caching the TokenYou'll end up with a The [
{
"startUrl": "$START_URL",
"region": "$REGION",
"accessToken": "$ACCESS_TOKEN",
"expiresAt": "$RFC3339_EXPIRY_TIMESTAMP"
}
] Obtaining Actual IAM CredentialsNow that you've gone through all of this, you can use the access token with use aws_sdk_sso::{Client as SsoClient};
use aws_sdk_sso::model::RoleCredentials;
let client = SsoClient::from_conf(config);
let role_credentials: RoleCredentials = client
.get_role_credentials()
.account_id(sso_account_id)
.role_name(sso_role_name)
.access_token(access_token)
.send()
.await?
.role_credentials
.unwrap(); This was a fun little deep-dive for me and hopefully it helps someone else as well. I'm not too familiar with how OIDC works, but I think I'm starting to understand a little bit. |
@naftulikay You are the hero we need but do not deserve... thank you so much. This is actually saving my company right now! |
This commit adds support for the SSO credential provider, which enables the aws-config to support using SSO when specified in
~/.aws/config
.Motivation and Context
awslabs/aws-sdk-rust#4
Description
This adds support for SSO, both as a standalone credentials provider, and with AWS config.
Testing
Checklist
CHANGELOG.next.toml
if I made changes to the smithy-rs codegen or runtime cratesCHANGELOG.next.toml
if I made changes to the AWS SDK, generated SDK code, or SDK runtime cratesBy submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.