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

fix arn comparison for IAM ARN #674

Merged
merged 1 commit into from
Dec 10, 2023

Conversation

nnmin-aws
Copy link
Contributor

@nnmin-aws nnmin-aws commented Dec 10, 2023

What this PR does / why we need it:
this PR fix the issue in PR 669. The original fix doesn't work.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Dec 10, 2023
@nnmin-aws
Copy link
Contributor Author

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Dec 10, 2023
@nnmin-aws nnmin-aws force-pushed the nnmin-fix2 branch 2 times, most recently from afc28b6 to 61b6ec4 Compare December 10, 2023 01:07
@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Dec 10, 2023
@nnmin-aws nnmin-aws force-pushed the nnmin-fix2 branch 2 times, most recently from 67fd86a to 8e336e5 Compare December 10, 2023 01:41
@nnmin-aws nnmin-aws changed the title fix arn comparison for IAM User fix arn comparison for IAM ARN Dec 10, 2023
@@ -46,31 +47,35 @@ func (m *DynamicFileMapper) Map(identity *token.Identity) (*config.IdentityMappi
}

if roleMapping, err := m.RoleMapping(key); err == nil {
if err := m.match(identity, roleMapping.RoleARN, roleMapping.UserId); err != nil {
if err := m.match(canonicalARN, roleMapping.RoleARN); err != nil {
Copy link
Contributor

@nckturner nckturner Dec 10, 2023

Choose a reason for hiding this comment

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

So should we remove the match call for role since only user ARNs can change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thank you for the comments! yeah we can refactor it in future

if m.userIDStrict {
// If ARN is provided, ARN must be validated along with UserID. This avoids having to
// support IAM user name/ARN changes. Without preventing this the mapping would look
// invalid but still work and auditing would be difficult/impossible.
strippedArn, _ := arn.StripPath(mappedARN)
if strippedArn != "" && token.CanonicalARN != strings.ToLower(strippedArn) {
// compare arn additionally for IAM user if principalId is used in mapping
Copy link
Contributor

@nckturner nckturner Dec 10, 2023

Choose a reason for hiding this comment

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

This comment is just restating the text above, I dont think it needs to be added.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thank you for the comments! yeah we can refactor it in future

@nckturner
Copy link
Contributor

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Dec 10, 2023
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: nckturner, nnmin-aws

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 10, 2023
@nnmin-aws
Copy link
Contributor Author

/merge

@nnmin-aws
Copy link
Contributor Author

/retest

@k8s-ci-robot k8s-ci-robot merged commit 36174a0 into kubernetes-sigs:master Dec 10, 2023
8 checks passed
@nnmin-aws nnmin-aws deleted the nnmin-fix2 branch December 10, 2023 03:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants