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

Fix basic authentication for browsers #3

Merged
merged 3 commits into from
Dec 4, 2023
Merged
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
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Fixed
- Fixed issue with incorrect headers and response code for browser/system level proxy settings
([#1](https://github.com/jthomperoo/simple-proxy/issues/1)).

## [v1.1.0] - 2022-04-08
## Added
### Added
- Basic auth support, can provide `--basic-auth 'username:password'` which the proxy then checks for valid auth
provided in the `Proxy-Authentication` header.
- Can choose if auth should be logged with the `--log-auth` option.
Expand Down
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,23 @@ Usage of simple-proxy:
comma-separated list of pattern=N settings for file-filtered logging
```

## Checking the proxy is working

You can use [cURL](https://curl.se/) on Linux/MacOS systems to check if your proxy is working:

```bash
curl --proxy 'http://localhost:8888' 'https://www.random.org/integers/?num=1&min=1&max=5&col=1&base=10&format=plain&rnd=new'
```

This will reach out to [random.org](https://www.random.org) to fetch a random number, using the default proxy address
and port.

On Windows you can use:

```powershell
curl.exe 'https://www.random.org/integers/?num=1&min=1&max=5&col=1&base=10&format=plain&rnd=new' --proxy 'http://localhost:8888'
```

## Contributing

See the [CONTRIBUTING](./CONTRIBUTING.md) and [CODE OF CONDUCT](./CODE_OF_CONDUCT.md) documents.
3 changes: 2 additions & 1 deletion proxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ func (p *ProxyHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
} else {
glog.Errorln("Unauthorized")
}
http.Error(w, "Unauthorized", http.StatusUnauthorized)
w.Header().Set("Proxy-Authenticate", "Basic")
http.Error(w, "Unauthorized", http.StatusProxyAuthRequired)
return
}
}
Expand Down
Loading