-
Notifications
You must be signed in to change notification settings - Fork 4k
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
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.
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.
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.
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.
Checks out
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:
PatchedSharedIniFileCredentials
because the upstreamSharedIniFileCredentials
has no SSO support at all; andSharedIniFileCredentials
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
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_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.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.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.Fixes #23520.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license