|
1 | 1 | package cmd |
2 | 2 |
|
3 | 3 | import ( |
4 | | - "fmt" |
5 | | - "os/user" |
6 | | - |
7 | 4 | "github.com/dnitsch/aws-cli-auth/internal/config" |
8 | 5 | "github.com/dnitsch/aws-cli-auth/internal/saml" |
9 | | - "github.com/dnitsch/aws-cli-auth/internal/util" |
10 | | - "github.com/dnitsch/aws-cli-auth/internal/web" |
11 | 6 | "github.com/spf13/cobra" |
12 | 7 | ) |
13 | 8 |
|
@@ -35,26 +30,14 @@ func init() { |
35 | 30 | } |
36 | 31 |
|
37 | 32 | func getSaml(cmd *cobra.Command, args []string) { |
38 | | - if cfgSectionName == "" { |
39 | | - util.Writeln("The SAML provider name is required") |
40 | | - util.Exit(nil) |
41 | | - } |
42 | | - |
43 | | - t, err := web.GetSamlLogin(providerUrl, acsUrl) |
44 | | - if err != nil { |
45 | | - fmt.Printf("Err: %v", err) |
| 33 | + conf := config.SamlConfig{ |
| 34 | + ProviderUrl: providerUrl, |
| 35 | + PrincipalArn: principalArn, |
| 36 | + Duration: duration, |
| 37 | + AcsUrl: acsUrl, |
| 38 | + BaseConfig: config.BaseConfig{StoreInProfile: storeInProfile, Role: role, CfgSectionName: cfgSectionName}, |
46 | 39 | } |
47 | | - user, err := user.Current() |
48 | | - if err != nil { |
49 | | - fmt.Errorf(err.Error()) |
50 | | - } |
51 | | - |
52 | | - roleObj := &util.AWSRole{RoleARN: role, PrincipalARN: principalArn, Name: util.SessionName(user.Username, config.SELF_NAME), Duration: duration} |
53 | 40 |
|
54 | | - creds, err := saml.LoginStsSaml(t, roleObj) |
55 | | - if err != nil { |
56 | | - fmt.Printf("%v", err) |
57 | | - } |
| 41 | + saml.GetSamlCreds(conf) |
58 | 42 |
|
59 | | - util.SetCredentials(creds, cfgSectionName, storeInProfile) |
60 | 43 | } |
0 commit comments