Summary#
- Implements
GET /v1/devices/:id/relay(MM-88): authenticated withdevice_token, returnsrelay_url,websocket_url, and optionaliroh_endpointfrom relay config - Adds
IrohConfig.endpoint: Option<String>tocommonconfig (TOML:[iroh] endpoint = "...", omitted =None) - Adds
require_device_token(headers, device_id, db)auth helper — scopes auth to both token hash and device ID path param, so a token from device A cannot authenticate requests for device B - Adds
seed_devicetest helper totest_utilsfor use across device-auth route tests
Test plan#
-
cargo test -p relay get_device_relay— 8 tests: 200 with correct URLs, relay_url matches config, websocket uses wss://, iroh_endpoint absent/present, 401 for no auth / wrong token / cross-device token -
cargo test -p relay device_token— 4 unit tests forrequire_device_token -
cargo test -p common iroh_endpoint— 2 config parsing tests -
cargo clippy --workspace -- -D warnings— clean -
cargo fmt --all --check— clean - Manual: register a device via
POST /v1/devices, callGET /v1/devices/:id/relaywith the returneddeviceTokenin Bruno