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

add proxy support for browser provider #739

Open
wants to merge 1 commit into
base: master
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ The process goes something like this:
* [Akamai](pkg/provider/akamai/README.md)
* OneLogin
* NetIQ
* Browser, this uses [playwright-go](github.com/mxschmitt/playwright-go) to run a sandbox chromium window.
* Browser, this uses [playwright-go](https://github.com/mxschmitt/playwright-go) to run a sandbox chromium window. Using ALL_PROXY environment variable you can set a proxy. HTTP and SOCKS proxies are supported, for example `http://myproxy.com:3128` or `socks5://myproxy.com:3128`. Short form `myproxy.com:3128` is considered an HTTP proxy.
* [Auth0](pkg/provider/auth0/README.md) NOTE: Currently, MFA not supported
* AWS SAML Provider configured

Expand Down
9 changes: 9 additions & 0 deletions pkg/provider/browser/browser.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package browser
import (
"errors"
"net/url"
"os"

"github.com/mxschmitt/playwright-go"
"github.com/sirupsen/logrus"
Expand Down Expand Up @@ -31,6 +32,7 @@ func (cl *Client) Authenticate(loginDetails *creds.LoginDetails) (string, error)
// TODO: provide some overrides for this window
launchOptions := playwright.BrowserTypeLaunchOptions{
Headless: playwright.Bool(false),
Proxy: GetProxy("ALL_PROXY"),
}

// currently using Chromium as it is widely supported for Identity providers
Expand Down Expand Up @@ -83,3 +85,10 @@ func (cl *Client) Validate(loginDetails *creds.LoginDetails) error {

return nil
}

func GetProxy(envVar string) *playwright.BrowserTypeLaunchOptionsProxy {
if value, ok := os.LookupEnv(envVar); ok {
return &playwright.BrowserTypeLaunchOptionsProxy{Server: playwright.String(value)}
}
return nil
}