[PR #3366] [CLOSED] [Other] Let a trusted LAN serve without an API key via STRATA_ALLOW_KEYLESS_BIND env variable #4593

Closed
opened 2026-11-07 15:37:41 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/3366
Author: @dsenchankau
Created: 10/20/2026
Status: ❌ Closed

Base: main ← Head: override-api-key-restriction


📝 Commits (1)

  • 40bd837 Other: serve keyless on a trusted LAN behind STRATA_ALLOW_KEYLESS_BIND

📊 Changes

4 files changed (+24 additions, -5 deletions)

View changed files

📝 docs/TERMINAL.md (+1 -1)
📝 serve/server.py (+11 -2)
📝 strata_cli/cli.py (+2 -2)
📝 tests/terminal/test_profiles.py (+10 -0)

📄 Description

Problem and result

Since v0.2.0-beta, the server started on 0.0.0.0 refuses with a non-loopback bind requires an inference API key and exit 2; Although 0.0.0.0 is not loopback, it's my local network, behind a firewall, and nothing else reaches it.

Now, if you set STRATA_ALLOW_KEYLESS_BIND=1 in the environment where strata starts, both strata serve and launch checks let the keyless bind through. The server prints a warning at startup so a stray env var stays visible: STRATA_ALLOW_KEYLESS_BIND is set: anyone who can reach this port can use the model. Unset or empty, nothing changes, same refusal, same message.

Approach

One helper, keyless_bind_allowed(), next to api_key_of in serve/server.py. Both gates call it: the server startup check and _launch_plan in strata_cli/cli.py, which already imports from serve.server. The gate checks the effective host, so it doesn't matter whether the host comes from the run config or from --host. It is an env var rather than a flag: the check runs in the process that starts the server, and a flag would need plumbing through launch, the TUI and the app. It is only read when the bind is non-loopback and no key was configured.

Validation

Passed:

  • .venv/bin/python -m unittest tests.terminal.test_profiles — 22 tests, OK. The new test_keyless_non_loopback_bind_needs_the_opt_in_env plans a profile with host=0.0.0.0, expects the refusal, and expects the plan to pass with the env var set.
  • .venv/bin/python -m unittest tests.terminal.test_launch — OK.
  • .venv/bin/python -m py_compile serve/server.py strata_cli/cli.py — no output (compiles).
  • STRATA_ALLOW_KEYLESS_BIND=1 python serve/server.py --engine strata --config <run config> --host 0.0.0.0 --port 1337 — the server started, no [strata] a non-loopback bind requires an inference API key error.

Failed:

  • None observed.

Not run:

  • N/A

Limits

  • The config JSON's env field doesn't help: it feeds the engine subprocess, the gate reads the server's own environment at startup.
  • If the owner-host daemon starts the server, set the var in the daemon's environment.
  • No --allow-keyless flag, nothing in the app or TUI.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/3366 **Author:** [@dsenchankau](https://github.com/dsenchankau) **Created:** 10/20/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `override-api-key-restriction` --- ### 📝 Commits (1) - [`40bd837`](https://github.com/Niko1221/Strata/commit/40bd83731a82fc0f52f24954b8e855e8df674299) Other: serve keyless on a trusted LAN behind STRATA_ALLOW_KEYLESS_BIND ### 📊 Changes **4 files changed** (+24 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `docs/TERMINAL.md` (+1 -1) 📝 `serve/server.py` (+11 -2) 📝 `strata_cli/cli.py` (+2 -2) 📝 `tests/terminal/test_profiles.py` (+10 -0) </details> ### 📄 Description ## Problem and result Since v0.2.0-beta, the server started on `0.0.0.0` refuses with `a non-loopback bind requires an inference API key` and exit 2; Although `0.0.0.0` is not loopback, it's my local network, behind a firewall, and nothing else reaches it. Now, if you set `STRATA_ALLOW_KEYLESS_BIND=1` in the environment where strata starts, both `strata serve` and `launch` checks let the keyless bind through. The server prints a warning at startup so a stray env var stays visible: `STRATA_ALLOW_KEYLESS_BIND is set: anyone who can reach this port can use the model`. Unset or empty, nothing changes, same refusal, same message. ## Approach One helper, `keyless_bind_allowed()`, next to `api_key_of` in `serve/server.py`. Both gates call it: the server startup check and `_launch_plan` in `strata_cli/cli.py`, which already imports from `serve.server`. The gate checks the effective host, so it doesn't matter whether the host comes from the run config or from `--host`. It is an env var rather than a flag: the check runs in the process that starts the server, and a flag would need plumbing through launch, the TUI and the app. It is only read when the bind is non-loopback and no key was configured. ## Validation Passed: - `.venv/bin/python -m unittest tests.terminal.test_profiles` — 22 tests, `OK`. The new `test_keyless_non_loopback_bind_needs_the_opt_in_env` plans a profile with `host=0.0.0.0`, expects the refusal, and expects the plan to pass with the env var set. - `.venv/bin/python -m unittest tests.terminal.test_launch` — `OK`. - `.venv/bin/python -m py_compile serve/server.py strata_cli/cli.py` — no output (compiles). - `STRATA_ALLOW_KEYLESS_BIND=1 python serve/server.py --engine strata --config <run config> --host 0.0.0.0 --port 1337` — the server started, no `[strata] a non-loopback bind requires an inference API key` error. Failed: - None observed. Not run: - N/A ## Limits - The config JSON's `env` field doesn't help: it feeds the engine subprocess, the gate reads the server's own environment at startup. - If the owner-host daemon starts the server, set the var in the daemon's environment. - No `--allow-keyless` flag, nothing in the app or TUI. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 15:37:41 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#4593
No description provided.