@@ -69,7 +69,7 @@ func getSaml(cmd *cobra.Command, args []string) error {
6969 if err != nil {
7070 return err
7171 }
72-
72+ allRoles := credentialexchange . InsertRoleIntoChain ( role , roleChain )
7373 conf := credentialexchange.CredentialConfig {
7474 ProviderUrl : providerUrl ,
7575 PrincipalArn : principalArn ,
@@ -81,28 +81,35 @@ func getSaml(cmd *cobra.Command, args []string) error {
8181 BaseConfig : credentialexchange.BaseConfig {
8282 StoreInProfile : storeInProfile ,
8383 Role : role ,
84- RoleChain : credentialexchange . InsertRoleIntoChain ( role , roleChain ) ,
84+ RoleChain : allRoles ,
8585 Username : user .Username ,
8686 CfgSectionName : cfgSectionName ,
8787 DoKillHangingProcess : killHangingProcess ,
8888 ReloadBeforeTime : reloadBeforeTime ,
8989 },
9090 }
9191
92+ saveRole := ""
9293 if isSso {
9394 sr := strings .Split (ssoRole , ":" )
9495 if len (sr ) != 2 {
9596 return fmt .Errorf ("incorrectly formatted role for AWS SSO - must only be ACCOUNT:ROLE_NAME" )
9697 }
98+ saveRole = ssoRole
99+
97100 conf .SsoUserEndpoint = fmt .Sprintf ("https://portal.sso.%s.amazonaws.com/user" , conf .SsoRegion )
98101 conf .SsoCredFedEndpoint = fmt .Sprintf ("https://portal.sso.%s.amazonaws.com/federation/credentials/" , conf .SsoRegion ) + fmt .Sprintf ("?account_id=%s&role_name=%s&debug=true" , sr [0 ], sr [1 ])
99102 }
100103
101104 datadir := path .Join (credentialexchange .HomeDir (), fmt .Sprintf (".%s-data" , credentialexchange .SELF_NAME ))
102105 os .MkdirAll (datadir , 0755 )
103106
104- secretStore , err := credentialexchange .NewSecretStore (conf .BaseConfig .Role ,
105- fmt .Sprintf ("%s-%s" , credentialexchange .SELF_NAME , credentialexchange .RoleKeyConverter (conf .BaseConfig .Role )),
107+ if len (allRoles ) > 0 {
108+ saveRole = allRoles [len (allRoles )- 1 ]
109+ }
110+
111+ secretStore , err := credentialexchange .NewSecretStore (saveRole ,
112+ fmt .Sprintf ("%s-%s" , credentialexchange .SELF_NAME , credentialexchange .RoleKeyConverter (saveRole )),
106113 os .TempDir (), user .Username )
107114 if err != nil {
108115 return err
0 commit comments