Skip to content

Commit e2245aa

Browse files
committed
fix: remove debug outputs
fix: add custom executable to cli flags
1 parent 4a82111 commit e2245aa

File tree

4 files changed

+25
-22
lines changed

4 files changed

+25
-22
lines changed

aws-cli-auth.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ func main() {
1717
go func() {
1818
<-ctx.Done()
1919
stop()
20-
log.Printf("\x1b[31minterrupted: %s\x1b[0m", ctx.Err())
20+
// log.Printf("\x1b[31minterrupted: %s\x1b[0m", ctx.Err())
2121
os.Exit(0)
2222
}()
2323

cmd/awscliauth.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ var (
1616
)
1717

1818
type Root struct {
19-
ctx context.Context
2019
Cmd *cobra.Command
2120
// ChannelOut io.Writer
2221
// ChannelErr io.Writer

cmd/saml.go

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,18 @@ const (
2626
)
2727

2828
type samlFlags struct {
29-
providerUrl string
30-
principalArn string
31-
acsUrl string
32-
isSso bool
33-
role string
34-
ssoRegion string
35-
ssoRole string
36-
ssoUserEndpoint string
37-
ssoFedCredEndpoint string
38-
datadir string
39-
samlTimeout int32
40-
reloadBeforeTime int
29+
providerUrl string
30+
principalArn string
31+
acsUrl string
32+
isSso bool
33+
role string
34+
ssoRegion string
35+
ssoRole string
36+
ssoUserEndpoint string
37+
ssoFedCredEndpoint string
38+
customExecutablePath string
39+
samlTimeout int32
40+
reloadBeforeTime int
4141
}
4242

4343
type samlCmd struct {
@@ -112,8 +112,9 @@ func newSamlCmd(r *Root) {
112112
return fmt.Errorf("failed to create session %s, %w", err, ErrUnableToCreateSession)
113113
}
114114
svc := sts.NewFromConfig(cfg)
115-
116-
return cmdutils.GetCredsWebUI(ctx, svc, secretStore, conf, web.NewWebConf(r.Datadir).WithTimeout(flags.samlTimeout))
115+
webConfig := web.NewWebConf(r.Datadir).WithTimeout(flags.samlTimeout)
116+
webConfig.CustomChromeExecutable = flags.customExecutablePath
117+
return cmdutils.GetCredsWebUI(ctx, svc, secretStore, conf, webConfig)
117118
},
118119
PreRunE: func(cmd *cobra.Command, args []string) error {
119120
if flags.reloadBeforeTime != 0 && flags.reloadBeforeTime > r.rootFlags.duration {
@@ -144,6 +145,12 @@ You should find it in the IAM portal e.g.: arn:aws:iam::1234567891012:saml-provi
144145
sc.cmd.PersistentFlags().StringVarP(&flags.ssoRole, "sso-role", "", "", "Sso Role name must be in this format - 12345678910:PowerUser")
145146
sc.cmd.PersistentFlags().StringVarP(&flags.ssoFedCredEndpoint, "sso-fed-endpoint", "", CredsEndpoint, "FederationCredEndpoint in a go style fmt.Sprintf string with a region placeholder")
146147
sc.cmd.PersistentFlags().StringVarP(&flags.ssoRegion, "sso-region", "", "eu-west-1", "If using SSO, you must set the region")
148+
sc.cmd.PersistentFlags().StringVarP(&flags.customExecutablePath, "executable-path", "", "", `Custom path to an executable
149+
150+
This needs to be a chromium like executable - e.g. Chrome, Chromium, Brave, Edge.
151+
152+
You can find out the path by opening your browser and typing in chrome|brave|edge://version
153+
`)
147154
sc.cmd.PersistentFlags().BoolVarP(&flags.isSso, "is-sso", "", false, `Enables the new AWS User portal login.
148155
If this flag is specified the --sso-role must also be specified.`)
149156
sc.cmd.PersistentFlags().IntVarP(&flags.reloadBeforeTime, "reload-before", "", 0, "Triggers a credentials refresh before the specified max-duration. Value provided in seconds. Should be less than the max-duration of the session")

internal/web/web.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -217,14 +217,11 @@ func (web *Web) GetSSOCredentials(conf credentialexchange.CredentialConfig) (str
217217
}
218218

219219
func (web *Web) MustClose() {
220-
if err := web.browser.Close(); err != nil {
221-
fmt.Fprintf(os.Stderr, "failed to close browser (PID: %v)", web.launcher.PID())
222-
}
220+
// swallows errors here - until a structured logger
221+
_ = web.browser.Close()
223222
utils.Sleep(0.5)
224223
// remove process just in case
225224
// os.Process is cross platform safe way to remove a process
226225
osprocess := os.Process{Pid: web.launcher.PID()}
227-
if err := osprocess.Kill(); err != nil {
228-
fmt.Fprintf(os.Stderr, "os/process kill err: %v", err)
229-
}
226+
_ = osprocess.Kill()
230227
}

0 commit comments

Comments
 (0)