Auth Capture Proxy
Auth Capture Proxy (authcaptureproxy) is a Python library and tool designed to create a proxy that captures authentication information from web pages. This is particularly useful for scenarios requiring the capture of OAuth login details without direct access to a third-party OAuth provider. The current version is 1.3.7, and the project maintains an active release cadence with frequent bug fixes and minor improvements.
Warnings
- breaking Version 1.2.0 introduced a hard dependency on Python 3.10 or newer. Users on older Python versions (e.g., 3.9) will encounter errors.
- gotcha Versions prior to 1.3.5 might incorrectly handle HTTP header duplication or fail to parse certain JSON responses, leading to unexpected proxy behavior or data corruption.
- gotcha Starting from version 1.3.1, the `base_url` parameter is automatically converted if it resembles a file URL. This might alter the intended target URL if you were explicitly passing file paths for other purposes.
- gotcha Version 1.3.3 introduced preconfiguration of the SSL context. If your application relies on specific low-level SSL context settings, this change might subtly alter behavior or require adjustments to your existing SSL configuration logic.
Install
-
pip install authcaptureproxy
Imports
- AuthCaptureProxy
from auth_capture_proxy.proxy import AuthCaptureProxy
Quickstart
import asyncio
from auth_capture_proxy.proxy import AuthCaptureProxy
async def run_proxy_example():
# Instantiate the proxy to listen on port 5000
# and forward requests to a target URL (e.g., a login page).
# authcaptureproxy will attempt to capture authentication details
# from the traffic passing through it.
proxy = AuthCaptureProxy(
listen_port=5000,
base_url="https://httpbin.org", # Use a real target URL for actual use
verbose=True
)
print("Starting Auth Capture Proxy on http://127.0.0.1:5000")
print("Forwarding traffic to https://httpbin.org")
print("Visit http://127.00.1:5000 in your browser to test.")
print("Press Ctrl+C to stop.")
try:
# Start the proxy server. This is an async operation.
await proxy.start()
# Keep the proxy running until interrupted.
# In a real application, integrate this into your event loop.
await asyncio.Event().wait()
except asyncio.CancelledError:
pass # Handle graceful shutdown
finally:
await proxy.stop()
print("Auth Capture Proxy stopped.")
if __name__ == "__main__":
try:
asyncio.run(run_proxy_example())
except KeyboardInterrupt:
print("\nExiting Auth Capture Proxy example.")