Skip to content

Commit

Permalink
retain original field
Browse files Browse the repository at this point in the history
  • Loading branch information
modulitos committed Aug 20, 2024
1 parent 1ecf00d commit c076692
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@ func (h *handler) authenticateEndpoint(w http.ResponseWriter, req *http.Request)
userExtra["canonicalArn"] = authenticationv1beta1.ExtraValue{identity.CanonicalARN}
userExtra["sessionName"] = authenticationv1beta1.ExtraValue{identity.SessionName}
userExtra["accessKeyId"] = authenticationv1beta1.ExtraValue{identity.AccessKeyID}
userExtra["principalId"] = authenticationv1beta1.ExtraValue{identity.UserID}
userExtra["eks.amazonaws.com/principalId"] = authenticationv1beta1.ExtraValue{identity.UserID}
}

Expand Down
10 changes: 10 additions & 0 deletions pkg/server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,7 @@ func TestAuthenticateVerifierRoleMapping(t *testing.T) {
"canonicalArn": authenticationv1beta1.ExtraValue{"arn:aws:iam::0123456789012:role/Test"},
"sessionName": authenticationv1beta1.ExtraValue{"TestSession"},
"accessKeyId": authenticationv1beta1.ExtraValue{"ABCDEF"},
"principalId": authenticationv1beta1.ExtraValue{"Test"},
"eks.amazonaws.com/principalId": authenticationv1beta1.ExtraValue{"Test"},
}))
validateMetrics(t, validateOpts{success: 1})
Expand Down Expand Up @@ -547,6 +548,7 @@ func TestAuthenticateVerifierRoleMappingCRD(t *testing.T) {
"canonicalArn": authenticationv1beta1.ExtraValue{"arn:aws:iam::0123456789012:role/Test"},
"sessionName": authenticationv1beta1.ExtraValue{"TestSession"},
"accessKeyId": authenticationv1beta1.ExtraValue{""},
"principalId": authenticationv1beta1.ExtraValue{"Test"},
"eks.amazonaws.com/principalId": authenticationv1beta1.ExtraValue{"Test"},
}))
validateMetrics(t, validateOpts{success: 1})
Expand Down Expand Up @@ -594,6 +596,7 @@ func TestAuthenticateVerifierUserMapping(t *testing.T) {
"canonicalArn": authenticationv1beta1.ExtraValue{"arn:aws:iam::0123456789012:user/Test"},
"sessionName": authenticationv1beta1.ExtraValue{"TestSession"},
"accessKeyId": authenticationv1beta1.ExtraValue{""},
"principalId": authenticationv1beta1.ExtraValue{"Test"},
"eks.amazonaws.com/principalId": authenticationv1beta1.ExtraValue{"Test"},
}))
validateMetrics(t, validateOpts{success: 1})
Expand Down Expand Up @@ -637,6 +640,7 @@ func TestAuthenticateVerifierUserMappingCRD(t *testing.T) {
"canonicalArn": authenticationv1beta1.ExtraValue{"arn:aws:iam::0123456789012:user/Test"},
"sessionName": authenticationv1beta1.ExtraValue{"TestSession"},
"accessKeyId": authenticationv1beta1.ExtraValue{""},
"principalId": authenticationv1beta1.ExtraValue{"Test"},
"eks.amazonaws.com/principalId": authenticationv1beta1.ExtraValue{"Test"},
}))
validateMetrics(t, validateOpts{success: 1})
Expand Down Expand Up @@ -680,6 +684,7 @@ func TestAuthenticateVerifierAccountMappingForUser(t *testing.T) {
"canonicalArn": authenticationv1beta1.ExtraValue{"arn:aws:iam::0123456789012:user/Test"},
"sessionName": authenticationv1beta1.ExtraValue{"TestSession"},
"accessKeyId": authenticationv1beta1.ExtraValue{""},
"principalId": authenticationv1beta1.ExtraValue{"Test"},
"eks.amazonaws.com/principalId": authenticationv1beta1.ExtraValue{"Test"},
}))
validateMetrics(t, validateOpts{success: 1})
Expand Down Expand Up @@ -723,6 +728,7 @@ func TestAuthenticateVerifierAccountMappingForUserCRD(t *testing.T) {
"canonicalArn": authenticationv1beta1.ExtraValue{"arn:aws:iam::0123456789012:user/Test"},
"sessionName": authenticationv1beta1.ExtraValue{"TestSession"},
"accessKeyId": authenticationv1beta1.ExtraValue{""},
"principalId": authenticationv1beta1.ExtraValue{"Test"},
"eks.amazonaws.com/principalId": authenticationv1beta1.ExtraValue{"Test"},
}))
validateMetrics(t, validateOpts{success: 1})
Expand Down Expand Up @@ -766,6 +772,7 @@ func TestAuthenticateVerifierAccountMappingForRole(t *testing.T) {
"canonicalArn": authenticationv1beta1.ExtraValue{"arn:aws:iam::0123456789012:role/Test"},
"sessionName": authenticationv1beta1.ExtraValue{"TestSession"},
"accessKeyId": authenticationv1beta1.ExtraValue{""},
"principalId": authenticationv1beta1.ExtraValue{"Test"},
"eks.amazonaws.com/principalId": authenticationv1beta1.ExtraValue{"Test"},
}))
validateMetrics(t, validateOpts{success: 1})
Expand Down Expand Up @@ -809,6 +816,7 @@ func TestAuthenticateVerifierAccountMappingForRoleCRD(t *testing.T) {
"canonicalArn": authenticationv1beta1.ExtraValue{"arn:aws:iam::0123456789012:role/Test"},
"sessionName": authenticationv1beta1.ExtraValue{"TestSession"},
"accessKeyId": authenticationv1beta1.ExtraValue{""},
"principalId": authenticationv1beta1.ExtraValue{"Test"},
"eks.amazonaws.com/principalId": authenticationv1beta1.ExtraValue{"Test"},
}))
validateMetrics(t, validateOpts{success: 1})
Expand Down Expand Up @@ -857,6 +865,7 @@ func TestAuthenticateVerifierNodeMapping(t *testing.T) {
"canonicalArn": authenticationv1beta1.ExtraValue{"arn:aws:iam::0123456789012:role/TestNodeRole"},
"sessionName": authenticationv1beta1.ExtraValue{"i-0c6f21bf1f24f9708"},
"accessKeyId": authenticationv1beta1.ExtraValue{""},
"principalId": authenticationv1beta1.ExtraValue{"TestNodeRole"},
"eks.amazonaws.com/principalId": authenticationv1beta1.ExtraValue{"TestNodeRole"},
}))
validateMetrics(t, validateOpts{success: 1})
Expand Down Expand Up @@ -902,6 +911,7 @@ func TestAuthenticateVerifierNodeMappingCRD(t *testing.T) {
"canonicalArn": authenticationv1beta1.ExtraValue{"arn:aws:iam::0123456789012:role/TestNodeRole"},
"sessionName": authenticationv1beta1.ExtraValue{"i-0c6f21bf1f24f9708"},
"accessKeyId": authenticationv1beta1.ExtraValue{""},
"principalId": authenticationv1beta1.ExtraValue{"TestNodeRole"},
"eks.amazonaws.com/principalId": authenticationv1beta1.ExtraValue{"TestNodeRole"},
}))
validateMetrics(t, validateOpts{success: 1})
Expand Down

0 comments on commit c076692

Please sign in to comment.