Skip to content
This repository has been archived by the owner on Mar 5, 2024. It is now read-only.

Log session-name and external-id when logging credentials #447

Merged
merged 2 commits into from
Dec 8, 2020
Merged
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
16 changes: 14 additions & 2 deletions pkg/aws/sts/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,25 @@
package sts

import (
"strings"

log "github.com/sirupsen/logrus"
)

func CredentialsFields(identity *RoleIdentity, creds *Credentials) log.Fields {
return log.Fields{
fields := log.Fields{
"credentials.access.key": creds.AccessKeyId,
"credentials.expiration": creds.Expiration,
"credentials.role": identity.Role,
"credentials.role": identity.Role.ARN,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We were logging the entire Role object which isn't nescasary, this will log only the ARN string and not the nested object.

}

if identity.SessionName != "" {
fields["credentials.session-name"] = identity.SessionName
}

if identity.ExternalID != "" {
fields["credentials.external-id"] = strings.Repeat("*", len(identity.ExternalID))
}

return fields
}