https://github.com/pridkett/cookieproxy
A simple golang proxy that augments requests with cookies
https://github.com/pridkett/cookieproxy
cookie cookies golang http https proxy-server
Last synced: 2 months ago
JSON representation
A simple golang proxy that augments requests with cookies
- Host: GitHub
- URL: https://github.com/pridkett/cookieproxy
- Owner: pridkett
- License: mit
- Created: 2021-02-22T03:46:24.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2021-04-11T22:09:25.000Z (almost 5 years ago)
- Last Synced: 2024-06-20T22:35:08.660Z (almost 2 years ago)
- Topics: cookie, cookies, golang, http, https, proxy-server
- Language: Go
- Homepage:
- Size: 24.4 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# CookieProxy
Patrick Wagstrom <patrick@wagstrom.net>
February 2021
## Overview
This was made for a _very_ niche use case of needing to use [telegraf](telegraf) with a remote API that required cookies and non-standard authentication method to get those cookies. Using this tool you can proxy through those requests with the appropriate cookies.
## Usage
While CookieProxy works without a CookieJar, you'll first want to create a CookieJar for maximum awesomeness.
```bash
./cookieproxy -cookiejar ~/cookies.txt
```
You'll see that CookieProxy has started on port 8675 and is ready to proxy requests:
```bash
curl http://localhost:8675/p/?target=http://foo.com/bar.png
```
### Advanced Usage
I recently added support for querying a host to grab the cookies. This is particularly useful for my main use case of acting as an authenticated proxy to a Tesla Powerwall. When using it in this way you don't need to specify the `-cookiejar` argument, but instead pass a JSON object as a string to the `-request` argument.
```bash
./cookieproxy -request '{"url": "https://powerwall/api/login/Basic", "headers": {"Content-Type": "application/json"}, "body": "{\\"username\\":\\"customer\\",\\"password\\":\\"YOUR_POWERWALL_PASSWORD\\",\\"force_sm_off\\":false}", "method": "POST"}'
```
Then you can easily validate it with the following command:
```bash
curl "http://localhost:8675/p/?target=https://powerwall/api/meters/aggregates"
```
## License
Copyright © 2021 Patrick Wagstrom
Licensed under terms of the MIT License