1ccacad63281094de8a3372d5a507d38f9969e5c
1
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
e053c337aa |
gateway: join a shared magpie with a password (EV_John_Liu on X)
EV_John_Liu asked for quick setup on a LAN: the central magpie serves a
page behind a password where other PCs and Macs get their config and a
new key of their own.
Settings -> Network and sharing -> Join with a password sets the
password (at least 8 characters; only a salted PBKDF2-SHA256 hash is
kept, in join.json, 0600, written through temp-and-rename; a file that
can't be read or parsed means joining is closed). The row then shows the
address to give out, <shared address>/join, and Turn off joining.
/join is the key page (/me) opened to join: the visitor types a name for
the computer and the password. POST /v1/magpie/join makes a gateway key
named after that computer (or "Joined from <ip>"). The key is listed in
Gateway keys like any other, where it can be limited or removed. The
page shows the key once and then the setup for that key: Claude Code,
Codex, a new magpie tab (`magpie provider add remote-magpie '<key>'
url='<address>'`), OpenAI-compatible and curl.
Every route judged:
- lanGuard lets another machine reach GET /join and the join route
without a key, only while magpie is shared. The route checks the
password itself.
- A browser's POST must come from the page itself. Host must be one of
this computer's own names (IP, localhost, MAGPIE_PUBLIC_URL's, its
hostname), so a DNS-rebound name is refused. Origin must equal Host.
Missing Origin and Origin "null" are refused, and so is any
Sec-Fetch-Site but same-origin. corsGuard still refuses null, foreign
and *.localhost Origins before this. curl and scripts, which send no
browser marks, are judged on the password alone.
- Throttle: each try from another machine costs a token, a right
password too. The bucket holds 10 and refills one every 10s, so a
guesser gets about 360 tries an hour, and a flood of tries makes no
flood of keys. Over the limit the route answers 429 with Retry-After.
- The password and key never go in a URL or a log line. The key comes
back only in a no-store 201 body. Logs name the key's id and the
caller's address.
- The routes are classed in the key-slot and read-only route lists.
They carry no key.
Run on mote at this head (rebased on
|