Skip to content

Harden for public release and rename to sub2api - #6

Merged
devbymak merged 5 commits into
mainfrom
harden-for-public-release
Oct 12, 2026
Merged

devbymak merged 5 commits into
mainfrom
harden-for-public-release

Conversation

@devbymak

@devbymak devbymak commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Gets the repo ready for other people to deploy and reuse.

Security fixes

  • Closes a 15-second window with no key check. The guard that refuses API calls while CPA has no keys cached CPA's answer per Worker isolate. After the last key was deleted, other isolates kept forwarding for up to 15s, and CPA lets every call through while its key list is empty. All requests now run in the single Cpa Durable Object, so one KeyGuard sees every dashboard change. After any dashboard write, no cached answer is trusted for 15s, in case CPA applies the change late.
  • Rate-limits sign-in. POST /login now allows 5 attempts a minute per IP (the Workers Rate Limiting binding LOGIN_LIMIT), and returns 429 after that.

Audit

  • Scanned all 12 commits of history for API keys, tokens, account IDs and private keys. Only test fixtures matched.
  • .dev.vars and .wrangler/ are gitignored and were never committed.

Docs

  • Shorter README built around keywords (CLIProxyAPI, Cloudflare, Claude Code, Codex, Gemini, OpenAI-compatible), with the one-click deploy up front.
  • New SECURITY.md: the security model, plus private vulnerability reporting.
  • package.json gains repository, homepage, license and keyword metadata.

Rename to sub2api

  • The repo, Worker, R2 bucket, package and login page are now sub2api. The default URL becomes sub2api.<subdomain>.workers.dev.
  • New README intro: "a Cloudflare-based LLM gateway and proxy server. Literally the CPA project, deployed as a Cloudflare Worker in one click."
  • An existing llm-gateway deploy is not touched. Deploying this creates a new Worker and an empty bucket, so providers need signing in again.

Tested

  • npm run verify: 55 tests pass, including new tests for the cache window and the rate limit.
  • wrangler deploy --dry-run builds and shows the LOGIN_LIMIT binding.
  • Ran end to end in wrangler dev with the real container:
    • With no keys, any API call gets 401.
    • With a key added, it gets 200, and a wrong key gets 401.
    • Right after deleting all keys, an API call gets 401.
    • The 6th sign-in attempt within a minute gets 429.

🤖 Generated with Claude Code

The guard that refuses API calls while CPA has no keys cached CPA's
answer per Worker isolate, so after the last key was removed other
isolates kept forwarding for up to 15 seconds, which CPA lets through.
Requests now run in the single Durable Object in front of the
container, and no cached answer is trusted for a window after any
dashboard write.

Sign-in attempts are limited to 5 a minute per client IP.
Short, keyword-led README with the one-click deploy up front; the
security model and a private reporting channel move to SECURITY.md.
Adds repository metadata to package.json.
The Worker, R2 bucket, package, login page and docs now use sub2api,
and the README introduces it as a Cloudflare-based LLM gateway and
proxy server that deploys CPA.
@devbymak devbymak changed the title Harden for public release: shared key guard, sign-in rate limit, new README Harden for public release and rename to sub2api Oct 12, 2026
Move the key check to the Durable Object in the diagram, state the
secret rules, add OpenAI client env vars, an Update section, the
bucket and login steps for wrangler deploys, and how to recover a
lost management key.
@devbymak
devbymak merged commit a6e75a5 into main Oct 12, 2026
4 checks passed
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