Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/browser extra flags #801

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions pkg/assume/assume.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ func processArgsAndExecFlag(c *cli.Context, assumeFlags *cfflags.Flags) (string,
}

func AssumeCommand(c *cli.Context) error {

// assumeFlags allows flags to be passed on either side of the role argument.
// to access flags in this command, use assumeFlags.String("region") etc instead of c.String("region")
assumeFlags, err := cfflags.New("assumeFlags", GlobalFlags(), c)
Expand Down Expand Up @@ -429,8 +430,8 @@ func AssumeCommand(c *cli.Context) error {

var l Launcher
switch cfg.DefaultBrowser {
case browser.ChromeKey, browser.BraveKey, browser.EdgeKey, browser.ChromiumKey, browser.VivaldiKey:
l = launcher.ChromeProfile{
case browser.ChromeKey, browser.BraveKey, browser.EdgeKey, browser.ChromiumKey:
l = launcher.Chrome{
BrowserType: cfg.DefaultBrowser,
ExecutablePath: browserPath,
}
Expand Down Expand Up @@ -471,6 +472,9 @@ func AssumeCommand(c *cli.Context) error {
return fmt.Errorf("error building browser launch command: %w", err)
}

// add browser extra flags here to avoid modifying all interface methods (current and future ones)
args = append(args, cfg.CustomBrowserExtraFlags...)

var startErr error
if l.UseForkProcess() {
clio.Debugf("running command using forkprocess: %s", args)
Expand Down
1 change: 0 additions & 1 deletion pkg/cfaws/assumer_aws_sso.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ func (c *Profile) SSOLogin(ctx context.Context, configOpts ConfigOpts) (aws.Cred

cfg := aws.NewConfig()
cfg.Region = c.SSORegion()

return c.SSOLoginWithToken(ctx, cfg, accessToken, secureSSOTokenStorage, configOpts)
}

Expand Down
5 changes: 3 additions & 2 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ type BrowserLaunchTemplate struct {
type Config struct {
DefaultBrowser string
// used to override the builtin filepaths for custom installation locations
CustomBrowserPath string
CustomSSOBrowserPath string
CustomBrowserPath string
CustomSSOBrowserPath string
CustomBrowserExtraFlags []string

// AWSConsoleBrowserLaunchTemplate is an optional launch template to use
// for opening the AWS console. If specified it overrides the DefaultBrowser
Expand Down
10 changes: 5 additions & 5 deletions pkg/granted/console.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,23 +74,23 @@ var ConsoleCommand = cli.Command{
} else {
switch cfg.DefaultBrowser {
case browser.ChromeKey:
l = launcher.ChromeProfile{
l = launcher.Chrome{
ExecutablePath: cfg.CustomBrowserPath,
}
case browser.BraveKey:
l = launcher.ChromeProfile{
l = launcher.Chrome{
ExecutablePath: cfg.CustomBrowserPath,
}
case browser.EdgeKey:
l = launcher.ChromeProfile{
l = launcher.Chrome{
ExecutablePath: cfg.CustomBrowserPath,
}
case browser.ChromiumKey:
l = launcher.ChromeProfile{
l = launcher.Chrome{
ExecutablePath: cfg.CustomBrowserPath,
}
case browser.VivaldiKey:
l = launcher.ChromeProfile{
l = launcher.Chrome{
ExecutablePath: cfg.CustomBrowserPath,
}
case browser.FirefoxKey:
Expand Down
6 changes: 3 additions & 3 deletions pkg/launcher/chrome_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ import (
"github.com/common-fate/granted/pkg/browser"
)

type ChromeProfile struct {
type Chrome struct {
// ExecutablePath is the path to the Chrome binary on the system.
ExecutablePath string

BrowserType string
}

func (l ChromeProfile) LaunchCommand(url string, profile string) ([]string, error) {
func (l Chrome) LaunchCommand(url string, profile string) ([]string, error) {
// Chrome profiles can't contain slashes
profileName := strings.ReplaceAll(profile, "/", "-")
profileDir := findBrowserProfile(profileName, l.BrowserType)
Expand Down Expand Up @@ -249,4 +249,4 @@ func getLocalStatePath(browserType string) (stateFile string, err error) {
return stateFile, nil
}

func (l ChromeProfile) UseForkProcess() bool { return true }
func (l Chrome) UseForkProcess() bool { return true }