Repository navigation
Access token for the public tunnel - #5
Merged
Merged
Conversation
launcher.py publishes Apollo on a public trycloudflare.com URL, and Apollo had no authentication: anyone with the link could read uploaded documents, upload files and run ComfyUI or LoRA jobs on the host GPU. The tunnel's requests reach uvicorn from localhost, so the fix cannot trust "local" either. - With APOLLO_ACCESS_TOKEN set, every request except /live and /health needs the token: the X-Apollo-Token header, or an HttpOnly, SameSite=Lax cookie that opening /?token=<token> sets once (then redirects without the token). Constant-time comparison. Unset, Apollo stays open as a local tool. - The launcher generates a token (unless you set one), and prints, copies and opens the link with the token. - 6 tests; checked in a browser: no token 401, the link sets the cookie and lands on /, all 7 of the page's API calls succeed. 259 tests pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With allow_origins=["*"] and allow_credentials=True, Starlette echoes the caller's Origin whenever the request carries a cookie, so another site could read responses made with the access cookie (checked: Origin evil + cookie -> allow-origin evil, allow-credentials true). The dashboard is same-origin and needs no CORS; API clients use the header. Credentials off; a test pins it. 260 tests pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
nosniff, X-Frame-Options DENY plus CSP frame-ancestors/base-uri/object-src (the directives that cannot break the dashboard's inline scripts), and Referrer-Policy no-referrer: the token arrives once in a URL, so no Referer header may carry it anywhere. The middleware wraps the token check, so the 401 and the cookie redirect carry the headers too. Test included. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
launcher.py, the README's main way to start Apollo, always opens a publictrycloudflare.comtunnel, and Apollo had no authentication. Anyone with that link could read your uploaded documents and chats, upload files, and run ComfyUI generations or LoRA training on your GPU. The tunnel's requests reach uvicorn fromlocalhost, so an "only allow local" rule wouldn't help.What changes:
APOLLO_ACCESS_TOKENset, every request except/liveand/health(the launcher's probes) needs the token. It's compared in constant time. It can come from:X-Apollo-Tokenheader, for API clients, or/?token=<token>sets once. The cookie is HttpOnly, SameSite=Lax (so other sites' requests never carry it), and Secure behind the tunnel. The page then redirects to the same URL without the token, and all of the page's own requests work unchanged.Tests:
tests/test_access_token.py(6) covers:/with the cookie set. All 7 of the page's API calls then succeed (/healthreports 503 only because Ollama wasn't running).CORS (second commit):
allow_origins=["*"]withallow_credentials=Truemade Starlette echo any caller's Origin when a cookie came along, so another site could read responses made with the access cookie. I checked it: a request from an evil origin with the cookie got back that origin andallow-credentials: true. Credentials are now off. The dashboard is same-origin, and API clients use the header. A test pins this; 260 tests pass.Security headers (third commit), on every response including the 401 and the redirect:
nosniff,X-Frame-Options: DENYwith CSPframe-ancestors 'none'; base-uri 'self'; object-src 'none'(the directives that can't break the dashboard's inline scripts), andReferrer-Policy: no-referrer. The token arrives once in a URL, so no Referer header may carry it anywhere.🤖 Generated with Claude Code