A simple proxy server that adds IAP (Identity-Aware Proxy) authentication headers to requests. It forwards requests from http://localhost:8080 to a configured backend URL with the necessary Google Cloud IAP credentials.
- Python 3.11+
- Google Cloud credentials configured (e.g., via
gcloud auth application-default login)
pip install -e .Run the proxy server from the src directory:
cd src
python -m test-proxy.mainThe proxy will start on http://localhost:8080 and forward all incoming requests to the configured backend URL.
| Variable | Description | Required |
|---|---|---|
IAP_CLIENT_ID |
The OAuth 2.0 client ID for the IAP-protected resource. This is critical for proxy authorization to succeed. | Yes |
TEST_BACKEND_URL |
The backend URL to forward requests to. | Yes |
TARGET_SERVICE_ACCOUNT |
The service account email to impersonate for generating IAP tokens. | Yes |
export IAP_CLIENT_ID="your-client-id.apps.googleusercontent.com"
export TEST_BACKEND_URL="https://your-backend-service.example.com"
export TARGET_SERVICE_ACCOUNT="your-service-account@your-project.iam.gserviceaccount.com"
python -m test-proxy.main- The proxy intercepts all HTTP requests on
localhost:8080 - It generates an IAP bearer token by impersonating the configured service account
- It forwards the request to the backend URL with
AuthorizationandProxy-Authorizationheaders containing the IAP token - The response from the backend is returned to the original client