Skip to content

Commit

Permalink
Truncate usernames getfederationtoken (#145)
Browse files Browse the repository at this point in the history
* added basic name truncation

* clean code

* Update pkg/cfaws/assumer_aws_iam.go

* added comment

Co-authored-by: JoshuaWilkes <[email protected]>
  • Loading branch information
meyerjrr and JoshuaWilkes authored Apr 19, 2022
1 parent 5a77710 commit 8227d34
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pkg/cfaws/assumer_aws_iam.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,15 @@ func getFederationToken(ctx context.Context, c *CFSharedConfig) (aws.Credentials
}

client := sts.NewFromConfig(cfg)
out, err := client.GetFederationToken(ctx, &sts.GetFederationTokenInput{Name: aws.String("Granted@" + c.Name), Policy: aws.String(allowAllPolicy)})
name := "Granted@" + c.Name

//getfederationtoken fails if name is longer than 32 characters long
//truncating the name to 32 characters if its longer than 32
if len(name) > 32 {
name = name[0:32]
}
out, err := client.GetFederationToken(ctx, &sts.GetFederationTokenInput{Name: aws.String(name), Policy: aws.String(allowAllPolicy)})

if err != nil {
return aws.Credentials{}, err
}
Expand Down

0 comments on commit 8227d34

Please sign in to comment.