Skip to content

Commit

Permalink
Limit role session name length to 64 characters.
Browse files Browse the repository at this point in the history
Originally fixed by @SinisterMinister

Fixes #741
  • Loading branch information
ajvb committed Apr 4, 2022
1 parent 268b5ff commit 1bb30e2
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions kms/keysource.go
Expand Up @@ -172,6 +172,13 @@ func (key MasterKey) createStsSession(config aws.Config, sess *session.Session)
sanitizedHostname := stsRoleSessionNameRe.ReplaceAllString(hostname, "")
stsService := sts.New(sess)
name := "sops@" + sanitizedHostname

// Make sure the name is no longer than 64 characters (role session name length limit from AWS)
roleSessionNameLengthLimit := 64
if len(name) >= roleSessionNameLengthLimit {
name = name[:roleSessionNameLengthLimit]
}

out, err := stsService.AssumeRole(&sts.AssumeRoleInput{
RoleArn: &key.Role, RoleSessionName: &name})
if err != nil {
Expand Down

0 comments on commit 1bb30e2

Please sign in to comment.