Skip to content

Commit 70d0b29

Browse files
Ali SadeghiArdestani
Ali Sadeghi
authored and
Ardestani
committed
add proxy support for browser provider
1 parent 8c1b6fe commit 70d0b29

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ The process goes something like this:
5252
* [Akamai](pkg/provider/akamai/README.md)
5353
* OneLogin
5454
* NetIQ
55-
* Browser, this uses [playwright-go](github.com/mxschmitt/playwright-go) to run a sandbox chromium window.
55+
* 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.
5656
* [Auth0](pkg/provider/auth0/README.md) NOTE: Currently, MFA not supported
5757
* AWS SAML Provider configured
5858

pkg/provider/browser/browser.go

+9
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package browser
33
import (
44
"errors"
55
"net/url"
6+
"os"
67

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

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

8486
return nil
8587
}
88+
89+
func GetProxy(envVar string) *playwright.BrowserTypeLaunchOptionsProxy {
90+
if value, ok := os.LookupEnv(envVar); ok {
91+
return &playwright.BrowserTypeLaunchOptionsProxy{Server: playwright.String(value)}
92+
}
93+
return nil
94+
}

0 commit comments

Comments
 (0)