Skip to content
Source
Sign inSign up
TanStack/source

feat: connect Cloudflare with OAuth for protected deployments #3

Opentannerlinsley opened this issue 1 comment
tannerlinsleycommented

Add a first-party Cloudflare connection so a repository admin can click Connect Cloudflare, authorize a scoped OAuth application, choose an account and Worker, and enable deployment after required checks pass.

Use Cloudflare's self-managed OAuth clients. Keep access and refresh tokens in Source's vault, refresh them outside job containers, support disconnect and revocation, and let protected deployment jobs use placeholders through the outbound handler. Pull requests must never gain production credentials. Keep repositories, build output and container images private.

The current protected CLOUDFLARE_API_TOKEN secret remains the supported setup until this is implemented. Connecting the integration should replace that manual setup without changing the repository's workflow or deployment gates.

Cloudflare docs: https://developers.cloudflare.com/changelog/post/2026-06-03-public-oauth-clients/

  1. Setup for the Cloudflare OAuth test (private client, nothing permanent)

    We want to test the OAuth flow before we build it. Four things are not in Cloudflare's docs: whether an OAuth token works for wrangler deploy and for the container registry, how long a token lives, and how we learn which account the person picked. To test them we need a private OAuth client in the TanStack Cloudflare account. My account cannot create one.

    1. Cloudflare dashboard, TanStack account > Manage Account > OAuth clients > Create.
    2. Name TanStack Source, client URL https://source.tanstack.com, auth method client_secret_basic.
    3. Redirect URIs: https://source.tanstack.com/cloudflare-oauth/callback and http://localhost:5173/cloudflare-oauth/callback.
    4. Required scopes: Account Settings Read, User Details Read, Workers Scripts Write. Optional scopes: Workers Containers Write, D1 Write, Queues Write, Workers KV Storage Write, Workers R2 Storage Write, Workers Routes Write.
    5. Keep it private. Do not make it public yet. That step cannot be undone.
    6. Copy the client id and the secret (Cloudflare shows the secret only once), and send them to Alem through a secure channel, not in this issue.

Sign in to join this conversation.