feat: remote access via Tailscale using [server].trusted_origins#60
Open
hkrathore wants to merge 1 commit into
Open
feat: remote access via Tailscale using [server].trusted_origins#60hkrathore wants to merge 1 commit into
hkrathore wants to merge 1 commit into
Conversation
Adds a config.local.toml setting that lets users allow additional HTTPS origins (e.g. their Tailscale HTTPS hostname) past the same-origin check without binding the server to 0.0.0.0. - config.toml: document new [server].trusted_origins key (default empty) - config.local.toml.example: show how to set it for a tailnet hostname - config_loader: merge [server].trusted_origins from config.local.toml into the effective config, deduplicating while preserving order - app: _build_allowed_origins() combines the localhost defaults with trusted_origins; SecurityMiddleware uses the merged set unchanged - README: full Tailscale remote-access guide — install, config, Serve This keeps the local-only model (host still binds 127.0.0.1) and only whitelists exact HTTPS origins. No behavior change when trusted_origins is empty. All existing tests pass.
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.
Summary
Adds a
[server].trusted_originsconfig (settable inconfig.local.toml) that lets users allow additional HTTPS origins past the same-origin check without binding the server to0.0.0.0. This enables remote access from a phone or another device via Tailscale while keeping the project's localhost-only security model intact.Motivation
I wanted to reach agentchattr from my phone while it keeps running on my Mac mini / Oracle VPS.
--allow-networkexposes the server over unencrypted HTTP on the LAN, which the README already warns against. Tailscale provides a private HTTPS entrypoint that's a much better fit, but the existing origin check rejects anything buthttp://127.0.0.1:PORT/http://localhost:PORT.What changed
config.toml— document the new[server].trusted_originskey (default[], so no behavior change for existing users)config.local.toml.example— show how to set it to a tailnet hostnameconfig_loader.py— merge[server].trusted_originsfromconfig.local.tomlinto the effective config, dedupe while preserving orderapp.py— extract_build_allowed_origins(cfg)which combines the existing localhost defaults withtrusted_origins;SecurityMiddlewareuses the merged set, logic otherwise unchangedREADME.md— full Tailscale remote-access guide under the existing "Network mode" section: install, config,tailscale serve, security notesDesign notes
127.0.0.1. The browser reaches the app via Tailscale Serve's reverse proxy; the app sees the Origin header from the tailnet hostname and allows it because it's in the whitelist.trusted_origins= no change from current behavior.Test plan
pytest tests/→ 42 passedtrusted_originsinconfig.local.tomlflows throughload_config→_build_allowed_origins, with dedupevil.example.com) →403 {"error":"forbidden: origin not allowed"}