|
| 1 | +--- |
| 2 | +id: upstream-auth |
| 3 | +title: Sauce Connect Upstream Authentication |
| 4 | +sidebar_label: Upstream Authentication |
| 5 | +--- |
| 6 | + |
| 7 | +Sauce Connect supports upstream HTTP authentication via the [`--auth`](/dev/cli/sauce-connect-5/run/#auth) flag. |
| 8 | +This flag allows the proxy to automatically send credentials to specified hosts. |
| 9 | +It is necessary when your site under test is protected by basic authentication, and you want Sauce Connect to handle authentication transparently for you. |
| 10 | + |
| 11 | +## Overview |
| 12 | + |
| 13 | +By using the [`--auth`](/dev/cli/sauce-connect-5/run/#auth) flag, you can instruct Sauce Connect to send authentication credentials automatically whenever a request matches a specific host and port. This works for: |
| 14 | + |
| 15 | +- Standard HTTP basic authentication prompts. |
| 16 | +- Authentication challenges triggered by clicks or form submissions. |
| 17 | + |
| 18 | +:::note |
| 19 | +All domains specified via the [`--auth`](/dev/cli/sauce-connect-5/run/#auth) flag are automatically [resigned](https://docs.saucelabs.com/secure-connections/sauce-connect-5/advanced/security-authentication/#ssl-certificate-bumping), as if they were passed using the [`--tls-resign-domains`](/dev/cli/sauce-connect-5/run/#tls-resign-domains) flag. |
| 20 | +::: |
| 21 | + |
| 22 | +## Usage |
| 23 | + |
| 24 | +To configure Sauce Connect to send credentials to an upstream server, use the following format: |
| 25 | + |
| 26 | +```bash |
| 27 | +--auth <username[:password]@host:port,...> |
| 28 | +``` |
| 29 | + |
| 30 | +### Example |
| 31 | + |
| 32 | +If your application is hosted at `mysite.com` and uses basic authentication with the username `awesometester` and password `supersekrit`, your command would look like this: |
| 33 | + |
| 34 | +```bash |
| 35 | +--auth awesometester: [email protected]:80 |
| 36 | +``` |
| 37 | +You can also use HTTPS (port `443`) or any other port that your upstream server is listening on. |
| 38 | + |
| 39 | +### Multiple Hosts |
| 40 | + |
| 41 | +You can provide the `--auth` flag multiple times to support multiple upstream hosts: |
| 42 | + |
| 43 | +```bash |
| 44 | +--auth awesometester: [email protected]:80 \ |
| 45 | +--auth awesometester: [email protected]:443 \ |
| 46 | +--auth awesometester: [email protected]:80 |
| 47 | +``` |
| 48 | + |
| 49 | +### Wildcard Matching |
| 50 | + |
| 51 | +You can use asterisks (*) to match any host and/or any port: |
| 52 | + |
| 53 | +```bash |
| 54 | +--auth awesometester:supersekrit@*:* |
| 55 | +``` |
| 56 | + |
| 57 | +This instructs Sauce Connect to send the credentials to all hosts and all ports it connects to. |
| 58 | + |
| 59 | +## Security Tip |
| 60 | + |
| 61 | +If you're concerned about exposing credentials in the command line (where they can be viewed in process lists), consider using environment variables instead. For more details, see [Using Environment Variables](/secure-connections/sauce-connect-5/guides/configuration/#environment-variables) |
0 commit comments