Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix: keep paired peers' media access after the instance password is removed
Adam Eivy472fd86c606f
diff --git a/client/src/components/instances/PeerSyncSecretEditor.jsx b/client/src/components/instances/PeerSyncSecretEditor.jsxindex 610d495fe3..ed792b6ebb 100644--- a/client/src/components/instances/PeerSyncSecretEditor.jsx+++ b/client/src/components/instances/PeerSyncSecretEditor.jsx@@ -10,7 +10,7 @@ function storedPasswordHint(peer) {return 'The saved instance password lets PortOS pair this peer. After it confirms the generated credential, remove the password here.';}if (peer.peerAuthAccepted) {- return 'This peer accepts the pair credential. Remove the stored password — it is no longer needed.';+ return 'This peer accepts the pair credential. Remove the password saved on this card — sync, media, and LLM requests to this peer use the pair credential. Keep each machine’s own instance password.';}return 'The instance password stays in use until this peer confirms the generated credential.';}diff --git a/docs/PEER_PUSH_AUTH.md b/docs/PEER_PUSH_AUTH.mdindex b77e623b77..eae1d3ed02 100644--- a/docs/PEER_PUSH_AUTH.md+++ b/docs/PEER_PUSH_AUTH.md@@ -89,6 +89,25 @@ receive `403 PEER_SCOPE_FORBIDDEN`, and the receiver logs one `⛔ Peer … refuoutside the federation surface` line per peer, method, and path. Adding a peercall site means adding its entry in the same change.+### Using a peer's image, video, and LLM services++Once a peer card reports **Peer confirmed the matching sync credential**, the+password saved on that card is no longer needed for anything that peer serves+you. Removing it does not affect federated image, video, and audio jobs+(`/api/federation/media/v1/*`), fleet LLM host discovery and key retrieval+(`/api/providers/fleet-host*`), or sync, because each request carries the peer+token. Inference itself goes straight to the host's fleet LLM port with that+host's API key, separate from PortOS authentication.++"Remove the stored password" refers only to the copy of the **peer's** password+saved on your peer card. Keep each machine's own instance password; it protects+that machine's operator routes. **Rotate pair secret** needs the peer's password+again, so save it back on the card when you rotate the secret.++A media host with no instance password still verifies the pair token on the+federation surface, so its provider keeps admitting paired peers. Automatic+pairing requires that host to have an instance password when the pair is set up.+Legacy HTTP Basic is the instance password itself, so it keeps operator reach(`method: 'basic'`, still refused host control). Its holder can already sign inat `/api/auth/login`, and the companion app uses it as a full sessiondiff --git a/server/services/authGate.js b/server/services/authGate.jsindex 0c24e3d921..051f7a6626 100644--- a/server/services/authGate.js+++ b/server/services/authGate.js@@ -133,7 +133,17 @@ export const authGate = async (req, res, next) => {req.managedVisitorAuth = await authenticateManagedVisitorRequest(req);return next();}- if (!enabled) return next();+ if (!enabled) {+ // The pair token is independent of the instance password, so a paired peer+ // stays identified after the password is removed: peer-provider routes+ // (federated media) require a verified peer and never take the auth-off+ // bypass. Only the federation surface is annotated; elsewhere the caller is+ // as anonymous as any other request to a password-free install.+ const peer = isPeerApiRequestAllowed(req.method, req.path.toLowerCase())+ ? await verifyPeerToken(req.headers) : null;+ if (peer) req.portosAuthContext = { enabled: false, authenticated: true, method: 'peer', peerId: peer.id };+ return next();+ }// CSRF guard runs FIRST, before isPublicPath — public endpoints like// /api/auth/logout still mutate state (clear the cookie + revoke the// session), so a same-tailnet attacker could force-logout a userdiff --git a/server/services/authGate.test.js b/server/services/authGate.test.jsindex 256a462214..4c251b453e 100644--- a/server/services/authGate.test.js+++ b/server/services/authGate.test.js@@ -679,6 +679,8 @@ describe('paired peer credential (#8356)', () => {app.post('/api/apps/:id/restart', (req, res) => res.json({ auth: req.portosAuthContext }));app.put('/api/settings', (req, res) => res.json({ auth: req.portosAuthContext }));app.post('/api/peer-sync/push', (req, res) => res.json({ auth: req.portosAuthContext }));+ app.get('/api/federation/media/v1/status', (req, res) => res.json({ auth: req.portosAuthContext }));+ app.post('/api/providers/fleet-host/key', (req, res) => res.json({ auth: req.portosAuthContext }));app.post('/api/commands/execute', requireHostControl, (_req, res) => res.json({ ran: true }));return app;};@@ -700,6 +702,9 @@ describe('paired peer credential (#8356)', () => {expect(read.status).toBe(200);expect(read.body.auth).toEqual({ enabled: true, authenticated: true, method: 'peer', peerId: 'peer-record' });expect((await withHeaders(request(app).post('/api/peer-sync/push').send({}), headers)).body.auth.method).toBe('peer');+ // A peer's media and LLM services need only the token, not a stored password.+ expect((await withHeaders(request(app).get('/api/federation/media/v1/status'), headers)).body.auth.method).toBe('peer');+ expect((await withHeaders(request(app).post('/api/providers/fleet-host/key').send({}), headers)).body.auth.method).toBe('peer');const exec = await withHeaders(request(app).post('/api/commands/execute').send({}), headers);expect(exec.status).toBe(403);@@ -748,6 +753,19 @@ describe('paired peer credential (#8356)', () => {expect(warn.mock.calls.some(([line]) => line.includes('POST /api/cos/tasks'))).toBe(true);});+ it('still identifies a paired peer on the federation surface after the instance password is removed', async () => {+ writePeers([pairedPeer()]);+ const app = await buildApp();+ const headers = await peerHeaders();++ const media = await withHeaders(request(app).get('/api/federation/media/v1/status'), headers);+ expect(media.body.auth).toEqual({ enabled: false, authenticated: true, method: 'peer', peerId: 'peer-record' });+ // Off the surface, and with a wrong secret, the caller stays anonymous.+ expect((await withHeaders(request(app).get('/api/example'), headers)).body.auth.method).toBeNull();+ const forged = await peerHeaders(PEER_ID, 'a-different-pair-secret-0123456789-xyz');+ expect((await withHeaders(request(app).get('/api/federation/media/v1/status'), forged)).body.auth.method).toBeNull();+ });+it('rejects a token for another instance, a wrong secret, a disabled peer, or an unpaired peer', async () => {const auth = await import('./auth.js');await auth.setPassword({ newPassword: 'example-password' });diff --git a/server/services/federatedMediaProvider.js b/server/services/federatedMediaProvider.jsindex e36e18f4a3..d9ef54a0e9 100644--- a/server/services/federatedMediaProvider.js+++ b/server/services/federatedMediaProvider.js@@ -309,7 +309,8 @@ export function normalizeFederatedMediaProviderConfig(settings) {* The provider is stricter than ordinary federation reads: it never inherits* authGate's auth-off bypass and never accepts a browser session. A verified* peer credential (the paired peer token, or legacy Basic) plus a registered,- * enabled caller is required every time.+ * enabled caller is required every time. The pair token is verified even on a+ * password-free install, so pairing keeps working after the password is removed.* Status discovery is expected to encounter disabled or misconfigured peers,* so callers can mark those denials as warnings: the HTTP response still tells* the consumer exactly why discovery failed, but it stays off this provider's