Skip to main content

cloud-run-readonly-proxy

A local reverse proxy for read-only access to IAM-protected Google Cloud Run services. It uses Application Default Credentials (ADC), either directly or as the source for service-account impersonation, and renews Cloud Run ID tokens without restarting the local listener. Only GET and HEAD requests are accepted.

Requirements

  • Python 3.11 or newer and uv
  • The Google Cloud CLI (gcloud) for initializing or refreshing ADC
  • ADC initialized with gcloud auth login --update-adc
  • roles/run.invoker on the Cloud Run service for either the ADC user or the impersonated service account

Service-account impersonation additionally requires roles/iam.serviceAccountTokenCreator on the impersonated service account.

Run

From PyPI:

uvx cloud-run-readonly-proxy@0.1.0 \
  --target-url TAGGED_OR_UNTAGGED_URL

Directly from a pinned public Git commit:

uvx --from 'git+https://github.com/alexei-ciobanu/cloud-run-readonly-proxy@COMMIT_SHA' \
  cloud-run-readonly-proxy \
  --target-url TAGGED_OR_UNTAGGED_URL

Then open http://localhost:8080.

Direct mode uses the user represented by ADC. That user must have Cloud Run Invoker on the service. Google documents these generic user ID tokens for development use; they are not bound to one target audience and are therefore more replayable than service-account ID tokens.

For an audience-bound token, use service-account impersonation:

uvx cloud-run-readonly-proxy@0.1.0 \
  --target-url TAGGED_OR_UNTAGGED_URL \
  --audience UNTAGGED_SERVICE_URL \
  --impersonate-service-account INVOKER_SA

For a traffic-tag URL, --target-url is the tagged URL while --audience remains the untagged service URL. --audience and --impersonate-service-account must be supplied together.

Other options:

--port PORT                 Local port; default: 8080
--auth-retry-seconds N      Delay after a failed token refresh; default: 5
--reauth-command COMMAND    Command launched or shown when ADC needs refreshing

Authentication and proxying

In direct mode the tool:

  1. loads user ADC directly through the Google authentication library;
  2. refreshes ADC and reads the returned OpenID Connect ID token; and
  3. starts a listener bound to 127.0.0.1 only.

When impersonation is requested, it instead uses ADC to call the IAM Credentials API and mint an audience-bound ID token for the explicitly configured service account.

The proxy reads each token's JWT expiration and refreshes it before expiry. If ADC expires while the process is running, the listener remains alive and serves a local recovery page instead of exiting. Select Sign in to run:

gcloud auth login --update-adc --quiet

The command opens the Google Cloud login flow in the system browser. After authentication succeeds, the originally requested page reloads automatically. The command is also displayed for manual use.

Only GET and HEAD requests are proxied. Authorization headers supplied by the browser are discarded and replaced with the generated Cloud Run token. Responses are streamed, redirects back to the Cloud Run origins are rewritten to localhost, and the system trust store is used for outbound TLS.

Local development

uv sync --dev
uv run ruff check .
uv run ruff format --check .
uv run ty check src
uv run cloud-run-readonly-proxy --help

License

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cloud_run_readonly_proxy-0.1.0.tar.gz (89.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cloud_run_readonly_proxy-0.1.0-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

File details

Details for the file cloud_run_readonly_proxy-0.1.0.tar.gz.

File metadata

  • Download URL: cloud_run_readonly_proxy-0.1.0.tar.gz
  • Upload date:
  • Size: 89.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for cloud_run_readonly_proxy-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3680f1115c9bd6e04e25edf2b9372eeb9abc708f36a38e15161c09461667c001
MD5 95faeb8ea442b82e65ae214f5d030162
BLAKE2b-256 c5a965f9832597a729865293410c35f14ea947ca8da4b744ce1804b26fbddf75

See more details on using hashes here.

File details

Details for the file cloud_run_readonly_proxy-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: cloud_run_readonly_proxy-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 13.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for cloud_run_readonly_proxy-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e38f152cccbb6abb3b56f675e7b66c6405ded288fcb0da85666c8075161df81a
MD5 b12fa732972a630b9bf000989092aedd
BLAKE2b-256 f2dc915de48a016fcde1656d9c41113098a70d5540174a2e02268fae316c03ce

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page