Skip to content

Commit

Permalink
add proxy support for browser provider
Browse files Browse the repository at this point in the history
  • Loading branch information
Ali Sadeghi authored and Ardestani committed Nov 3, 2021
1 parent 8c1b6fe commit 70d0b29
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
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
}

0 comments on commit 70d0b29

Please sign in to comment.