Skip to content

Commit a5116fa

Browse files
authored
Merge pull request #675 from nnmin-aws/nnmin-fix2
release v0.6.16
2 parents 3a99789 + 92c363c commit a5116fa

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

pkg/mapper/dynamicfile/mapper.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package dynamicfile
33
import (
44
"strings"
55

6+
"github.com/sirupsen/logrus"
67
"sigs.k8s.io/aws-iam-authenticator/pkg/arn"
78
"sigs.k8s.io/aws-iam-authenticator/pkg/config"
89
"sigs.k8s.io/aws-iam-authenticator/pkg/errutil"
@@ -46,31 +47,34 @@ func (m *DynamicFileMapper) Map(identity *token.Identity) (*config.IdentityMappi
4647
}
4748

4849
if roleMapping, err := m.RoleMapping(key); err == nil {
49-
if err := m.match(identity, roleMapping.RoleARN, roleMapping.UserId); err != nil {
50+
if err := m.match(canonicalARN, roleMapping.RoleARN); err != nil {
5051
return nil, err
5152
}
5253
return roleMapping.IdentityMapping(identity), nil
5354
}
5455

5556
if userMapping, err := m.UserMapping(key); err == nil {
56-
if err := m.match(identity, userMapping.UserARN, userMapping.UserId); err != nil {
57+
if err := m.match(canonicalARN, userMapping.UserARN); err != nil {
5758
return nil, err
5859
}
5960
return userMapping.IdentityMapping(identity), nil
60-
}
6161

62+
}
6263
return nil, errutil.ErrNotMapped
6364
}
6465

65-
func (m *DynamicFileMapper) match(token *token.Identity, mappedARN, mappedUserID string) error {
66+
func (m *DynamicFileMapper) match(canonicalARN string, mappingARN string) error {
6667
if m.userIDStrict {
6768
// If ARN is provided, ARN must be validated along with UserID. This avoids having to
6869
// support IAM user name/ARN changes. Without preventing this the mapping would look
6970
// invalid but still work and auditing would be difficult/impossible.
70-
strippedArn, _ := arn.StripPath(mappedARN)
71-
if strippedArn != "" && token.CanonicalARN != strings.ToLower(strippedArn) {
71+
strippedArn, _ := arn.StripPath(mappingARN)
72+
logrus.Infof("additional arn comparison for IAM arn. arn from STS response is %s, arn in mapper is %s",
73+
canonicalARN, strings.ToLower(strippedArn))
74+
if strippedArn != "" && canonicalARN != strings.ToLower(strippedArn) {
7275
return errutil.ErrIDAndARNMismatch
7376
}
77+
return nil
7478
}
7579
return nil
7680
}

version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.6.15
1+
0.6.16

0 commit comments

Comments
 (0)