You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat!: add GRANTED_BROWSER_PROFILE env var support for browser profile override (#914)
* feat!: add GRANTED_BROWSER_PROFILE env var support for browser profile override
Add support for GRANTED_BROWSER_PROFILE environment variable to override
the browser profile used when opening AWS console with -c/-s flags.
Changes:
- Add EnvVars to browser-profile flag to automatically read from
GRANTED_BROWSER_PROFILE environment variable
- Remove browser-profile from getConsoleURL condition to prevent env var
from inadvertently triggering console URL generation
- Browser profile from env var is only used when actually launching
browser (after all safety checks)
BREAKING CHANGE: The --browser-profile flag no longer triggers browser
opening by itself. Users must now explicitly use -c or -s flags along
with --browser-profile to open a browser. Previously, passing
--browser-profile alone would open a browser window, but now it only
sets which browser profile to use when a browser is opened via other
flags. This prevents the GRANTED_BROWSER_PROFILE environment variable
from inadvertently opening browsers.
This allows users to set a default browser profile via environment
variable that will be used whenever opening the console, while still
allowing --browser-profile flag to take precedence.
Fixes#886
* feat: add GRANTED_SSO_BROWSER_PROFILE env var support for SSO browser profile
Add support for GRANTED_SSO_BROWSER_PROFILE environment variable to override
the browser profile used when launching SSO login flows.
When using SSOBrowserLaunchTemplate, the environment variable will be used
to specify which browser profile to use for SSO authentication flows.
Usage:
export GRANTED_SSO_BROWSER_PROFILE="MySSOProfile"
assume <profile> # SSO login will use "MySSOProfile" as the browser profile
* feat: add --sso-browser-profile flag and GRANTED_SSO_BROWSER_PROFILE env var support
- Add --sso-browser-profile flag to assume, granted sso login, generate, and populate commands
- Add SSOBrowserProfile field to ConfigOpts to pass browser profile through SSO login flow
- Remove redundant environment variable check from idclogin.Login (handled by flag EnvVars)
- Add test case for empty browser profile in launcher tests
- Support GRANTED_SSO_BROWSER_PROFILE environment variable via flag EnvVars
Copy file name to clipboardExpand all lines: pkg/assume/entrypoint.go
+2-1Lines changed: 2 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -45,7 +45,8 @@ func GlobalFlags() []cli.Flag {
45
45
&cli.StringFlag{Name: "sso-region", Usage: "Use this in conjunction with --sso, the sso-region"},
46
46
&cli.StringFlag{Name: "account-id", Usage: "Use this in conjunction with --sso, the account-id"},
47
47
&cli.StringFlag{Name: "role-name", Usage: "Use this in conjunction with --sso, the role-name"},
48
-
&cli.StringFlag{Name: "browser-profile", Aliases: []string{"bp"}, Usage: "Use a pre-existing profile in your browser"},
48
+
&cli.StringFlag{Name: "browser-profile", Aliases: []string{"bp"}, Usage: "Use a pre-existing profile in your browser", EnvVars: []string{"GRANTED_BROWSER_PROFILE"}},
49
+
&cli.StringFlag{Name: "sso-browser-profile", Usage: "Use a pre-existing profile in your browser for SSO login", EnvVars: []string{"GRANTED_SSO_BROWSER_PROFILE"}},
49
50
&cli.StringFlag{Name: "mfa-token", Usage: "Provide your current MFA token for the role you are assuming to skip being prompted"},
50
51
&cli.StringFlag{Name: "save-to", Usage: "Use this in conjunction with --sso, the profile name to save the role to in your AWS config file"},
51
52
&cli.BoolFlag{Name: "export-all-env-vars", Aliases: []string{"x"}, Usage: "Exports all available credentials to the terminal when used with a profile configured for credential-process. Without this flag, only the AWS_PROFILE will be configured"},
Copy file name to clipboardExpand all lines: pkg/granted/sso.go
+16-8Lines changed: 16 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -55,7 +55,9 @@ var GenerateCommand = cli.Command{
55
55
&cli.StringFlag{Name: "sso-region", Usage: "Specify the SSO region"},
56
56
&cli.StringSliceFlag{Name: "source", Usage: "The sources to load AWS profiles from (valid values are: 'aws-sso')", Value: cli.NewStringSlice("aws-sso")},
57
57
&cli.BoolFlag{Name: "no-credential-process", Usage: "Generate profiles without the Granted credential-process integration"},
58
-
&cli.StringFlag{Name: "profile-template", Usage: "Specify profile name template", Value: awsconfigfile.DefaultProfileNameTemplate}},
58
+
&cli.StringFlag{Name: "profile-template", Usage: "Specify profile name template", Value: awsconfigfile.DefaultProfileNameTemplate},
59
+
&cli.StringFlag{Name: "sso-browser-profile", Usage: "Use a pre-existing profile in your browser for SSO login", EnvVars: []string{"GRANTED_SSO_BROWSER_PROFILE"}},
60
+
},
59
61
Action: func(c*cli.Context) error {
60
62
ctx:=c.Context
61
63
fullCommand:=fmt.Sprintf("%s %s", c.App.Name, c.Command.FullName()) // e.g. 'granted sso populate'
@@ -100,10 +102,11 @@ var GenerateCommand = cli.Command{
returnfmt.Errorf("the common fate profile source is no longer supported: https://www.commonfate.io/blog/winding-down")
109
112
default:
@@ -138,6 +141,7 @@ var PopulateCommand = cli.Command{
138
141
&cli.BoolFlag{Name: "prune", Usage: "Remove any generated profiles with the 'common_fate_generated_from' key which no longer exist"},
139
142
&cli.StringFlag{Name: "profile-template", Usage: "Specify profile name template", Value: awsconfigfile.DefaultProfileNameTemplate},
140
143
&cli.BoolFlag{Name: "no-credential-process", Usage: "Generate profiles without the Granted credential-process integration"},
144
+
&cli.StringFlag{Name: "sso-browser-profile", Usage: "Use a pre-existing profile in your browser for SSO login", EnvVars: []string{"GRANTED_SSO_BROWSER_PROFILE"}},
141
145
},
142
146
Action: func(c*cli.Context) error {
143
147
ctx:=c.Context
@@ -214,10 +218,11 @@ var PopulateCommand = cli.Command{
returnfmt.Errorf("the common fate profile source is no longer supported: https://www.commonfate.io/blog/winding-down")
223
228
default:
@@ -245,6 +250,7 @@ var LoginCommand = cli.Command{
245
250
&cli.StringFlag{Name: "sso-region", Usage: "Specify the SSO region"},
246
251
&cli.StringFlag{Name: "sso-start-url", Usage: "Specify the SSO start url"},
247
252
&cli.StringSliceFlag{Name: "sso-scope", Usage: "Specify the SSO scopes"},
253
+
&cli.StringFlag{Name: "sso-browser-profile", Usage: "Use a pre-existing profile in your browser for SSO login", EnvVars: []string{"GRANTED_SSO_BROWSER_PROFILE"}},
248
254
},
249
255
Action: func(c*cli.Context) error {
250
256
ctx:=c.Context
@@ -291,13 +297,14 @@ var LoginCommand = cli.Command{
0 commit comments