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

Support un-canonicalized ARNs in filemapper #506

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions pkg/mapper/file/mapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ func NewFileMapper(cfg config.Config) (*FileMapper, error) {
if err != nil {
return nil, err
}
if m.RoleARN != "" {
canonicalizedARN, err := arn.Canonicalize(m.RoleARN)
if err != nil {
return nil, err
}
m.RoleARN = canonicalizedARN
}
fileMapper.roleMap[m.Key()] = m
}
for _, m := range cfg.UserMappings {
Expand Down
11 changes: 11 additions & 0 deletions pkg/mapper/file/mapper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ func newConfig() config.Config {
Username: "cookie-cutter",
Groups: []string{"system:masters"},
},
{
// test compatibility with eks
RoleARN: "arn:aws:sts::012345678910:assumed-role/test-assumed-role/session-name",
Username: "test",
Groups: []string{"system:masters"},
},
},
UserMappings: []config.UserMapping{
{
Expand Down Expand Up @@ -57,6 +63,11 @@ func TestNewFileMapper(t *testing.T) {
Username: "cookie-cutter",
Groups: []string{"system:masters"},
},
"arn:aws:iam::012345678910:role/test-assumed-role": {
RoleARN: "arn:aws:iam::012345678910:role/test-assumed-role",
Username: "test",
Groups: []string{"system:masters"},
},
},
userMap: map[string]config.UserMapping{
"arn:aws:iam::012345678910:user/donald": {
Expand Down