Skip to content

feat: add Cloudflare Zero Trust (Access Service Token) support#4

Open
wardlive wants to merge 1 commit intoTrackLine:mainfrom
wardlive:feat/cloudflare-access-service-token
Open

feat: add Cloudflare Zero Trust (Access Service Token) support#4
wardlive wants to merge 1 commit intoTrackLine:mainfrom
wardlive:feat/cloudflare-access-service-token

Conversation

@wardlive
Copy link
Copy Markdown

What & Why

Many users run Remnawave behind a Cloudflare Tunnel + Cloudflare Access policy for Zero Trust protection. In this setup every HTTP request must carry two headers:

CF-Access-Client-Id: <Service Token ID>
CF-Access-Client-Secret: <Service Token Secret>

Without these headers Cloudflare returns a 403 Forbidden before the request ever reaches Remnawave, making the MCP server unusable in such environments.

Changes

src/config.ts

  • Added two optional fields to the Config interface:
    • cfAccessClientId?: string
    • cfAccessClientSecret?: string
  • Added corresponding env variable reads in loadConfig():
    • CF_ACCESS_CLIENT_ID
    • CF_ACCESS_CLIENT_SECRET

src/client/index.ts

  • In RemnawaveClient constructor: when cfAccessClientId / cfAccessClientSecret are present, they are appended to the outgoing headers map as CF-Access-Client-Id / CF-Access-Client-Secret.

Both fields are optional — existing users who don't use Cloudflare Access are completely unaffected (zero behaviour change for them).

Configuration

# Required as always
REMNAWAVE_BASE_URL=https://your-panel.example.com
REMNAWAVE_API_TOKEN=your-remnawave-api-token

# Optional — only needed when panel is behind Cloudflare Access
CF_ACCESS_CLIENT_ID=xxxxxxxxxxxxxxxx.access
CF_ACCESS_CLIENT_SECRET=yyyyyyyyyyyyyyyy

REMNAWAVE_READONLY=true

Service Tokens are created in: Cloudflare Zero Trust → Access → Service Auth → Service Tokens.

Tested

  • Cloudflare Tunnel → Caddy → Remnawave panel (CovenVPN production setup)
  • Both REMNAWAVE_READONLY=true (69 tools) and full mode (153 tools)
  • Confirmed: without the headers → 403; with headers → full API access

Docs reference

Adds support for authenticating through Cloudflare Zero Trust (Access)
using Service Tokens (CF-Access-Client-Id / CF-Access-Client-Secret headers).

This is needed when the Remnawave panel is protected by a Cloudflare
Tunnel + Access policy, which is a common production hardening setup.

New environment variables (both optional):
- CF_ACCESS_CLIENT_ID     → CF-Access-Client-Id header
- CF_ACCESS_CLIENT_SECRET → CF-Access-Client-Secret header

Tested with Cloudflare Tunnel + Caddy reverse proxy in front of
Remnawave panel. Service Auth policy in CF Access correctly bypasses
the login wall for machine-to-machine access.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant