Skip to content

Commit

Permalink
fix: Correct SamlConsolePrincipal for non-China (#24277)
Browse files Browse the repository at this point in the history
Closes #24243.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
Naumel committed Feb 22, 2023
1 parent 0b822b3 commit e47646c
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 41 deletions.
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-iam/lib/principals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,7 @@ export class SamlConsolePrincipal extends SamlPrincipal {
super(samlProvider, {
...conditions,
StringEquals: {
'SAML:aud': cdk.Aws.PARTITION==='aws-cn'? 'https://signin.amazonaws.cn/saml': `https://signin.${cdk.Aws.URL_SUFFIX}/saml`,
'SAML:aud': cdk.Aws.PARTITION==='aws-cn'? 'https://signin.amazonaws.cn/saml': 'https://signin.aws.amazon.com/saml',
},
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"version": "30.0.0",
"version": "30.1.0",
"files": {
"adc0eedec883653ef9cbd8c66ae68791bf952df8f678cf586e78e02997e2674c": {
"3b60cda5eb73f658ff1ab1a242bd0e399cc5307d4d6493cea0171e543c6f1cc8": {
"source": {
"path": "cdk-saml-provider.template.json",
"packaging": "file"
},
"destinations": {
"current_account-current_region": {
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
"objectKey": "adc0eedec883653ef9cbd8c66ae68791bf952df8f678cf586e78e02997e2674c.json",
"objectKey": "3b60cda5eb73f658ff1ab1a242bd0e399cc5307d4d6493cea0171e543c6f1cc8.json",
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,7 @@
"Action": "sts:AssumeRoleWithSAML",
"Condition": {
"StringEquals": {
"SAML:aud": {
"Fn::Join": [
"",
[
"https://signin.",
{
"Ref": "AWS::URLSuffix"
},
"/saml"
]
]
}
"SAML:aud": "https://signin.aws.amazon.com/saml"
}
},
"Effect": "Allow",
Expand All @@ -38,8 +27,7 @@
}
],
"Version": "2012-10-17"
},
"Description": "fix the partition issue"
}
}
}
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"version":"30.0.0"}
{"version":"30.1.0"}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "30.0.0",
"version": "30.1.0",
"testCases": {
"saml-provider-test/DefaultTest": {
"stacks": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "30.0.0",
"version": "30.1.0",
"artifacts": {
"cdk-saml-provider.assets": {
"type": "cdk:asset-manifest",
Expand All @@ -17,7 +17,7 @@
"validateOnSynth": false,
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}",
"cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}",
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/adc0eedec883653ef9cbd8c66ae68791bf952df8f678cf586e78e02997e2674c.json",
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/3b60cda5eb73f658ff1ab1a242bd0e399cc5307d4d6493cea0171e543c6f1cc8.json",
"requiresBootstrapStackVersion": 6,
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version",
"additionalDependencies": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "30.0.0",
"version": "30.1.0",
"files": {
"21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": {
"source": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,7 @@
"Action": "sts:AssumeRoleWithSAML",
"Condition": {
"StringEquals": {
"SAML:aud": {
"Fn::Join": [
"",
[
"https://signin.",
{
"Ref": "AWS::URLSuffix"
},
"/saml"
]
]
}
"SAML:aud": "https://signin.aws.amazon.com/saml"
}
},
"Effect": "Allow",
Expand All @@ -79,8 +68,7 @@
}
],
"Version": "2012-10-17"
},
"description": "fix the partition issue"
}
}
},
"constructInfo": {
Expand Down
1 change: 0 additions & 1 deletion packages/@aws-cdk/aws-iam/test/integ.saml-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ class TestStack extends Stack {

new iam.Role(this, 'Role', {
assumedBy: new iam.SamlConsolePrincipal(provider),
description: 'fix the partition issue',
});
}
}
Expand Down
4 changes: 1 addition & 3 deletions packages/@aws-cdk/aws-iam/test/principals.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,7 @@ test('SAML principal', () => {
Action: 'sts:AssumeRoleWithSAML',
Condition: {
StringEquals: {
'SAML:aud': {
'Fn::Join': ['', ['https://signin.', { Ref: 'AWS::URLSuffix' }, '/saml']],
},
'SAML:aud': 'https://signin.aws.amazon.com/saml',
},
},
Effect: 'Allow',
Expand Down

0 comments on commit e47646c

Please sign in to comment.