fix(cli): can not assume role from 2-level SSO#23702
Conversation
The CLI used to support this: ``` [profile sso] ... [profile one] ... source_profile = sso ``` But not this: ``` [profile sso] ... [profile one] ... source_profile = sso [profile two] ... source_profile = one ``` The reason was that: * We have to do an explicit detection of SSO source profiles in our `PatchedSharedIniFileCredentials` because the upstream `SharedIniFileCredentials` has no SSO support at all; and * When we recursed we would recurse using the `SharedIniFileCredentials` class. In combination, this means that we could only recurse **one level**, because in `SharedIniFileCredentials` we wouldn't support SSO profiles at all. Fix this by recursing using `SharedIniFileCredentials`, so that we can support SSO source profiles an arbitrary amount of nesting levels deep. While investigating this, also fixed the following issues: - SSO profiles would be detected using the incorrect key: `sso_start_url` can be specified either on the profile section, or a new `[sso-session]` section. `sso_account_id` however always must be on the profile section, so check on that. - Drop the `credentials/config` file loading patch. The upstream SDK has fixed this behavior in the mean time, so we can rely on the passed-in profile data again. - Dropped support for reading the STS AssumeRole `region` from the `[default]` section. After investigating by both the JS SDK team and myself, noticed that the AWS CLI does **not** support reading the region from there. While we are both in agreement this is a bug, all customers expect the CDK CLI to behave exactly the same as the AWS CLI, so we have to keep bug-for-bug compatibility.
aws-cdk-automation
left a comment
There was a problem hiding this comment.
The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.
|
SDK auth is extremely awkward to test, because it hasn't really been design to be unit tested and integration tests require extensive setup and maintenance. You'll have to trust this has been tested by hand. |
✅ Updated pull request passes all PRLinter validations. Dissmissing previous PRLinter review.
|
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
|
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
The CLI used to support this:
But not this:
The reason was that:
PatchedSharedIniFileCredentialsbecause the upstreamSharedIniFileCredentialshas no SSO support at all; andSharedIniFileCredentialsclass.In combination, this means that we could only recurse one level, because in
SharedIniFileCredentialswe wouldn't support SSO profiles at all.Fix this by recursing using
PatchedSharedIniFileCredentials, so that we can support SSO source profiles an arbitrary amount of nesting levels deep.While investigating this, also fixed the following issues:
sso_start_urlcan be specified either on the profile section, or a new[sso-session]section.sso_account_idhowever always must be on the profile section, so check on that.regionfrom the[default]section. After investigating by both the JS SDK team and myself, noticed that the AWS CLI does not support reading the region from there. While we are both in agreement this is a bug, all customers expect the CDK CLI to behave exactly the same as the AWS CLI, so we have to keep bug-for-bug compatibility.credentials/configfile loading patch. The upstream SDK has fixed this behavior in the mean time, so we can rely on the passed-in profile data again.Fixes #23520.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license