Three phones on one account now produce one history, which is the main reason to have accounts beyond upload permission. GET /v1/runs returns the account's runs and says how many devices contributed; fetching and deleting resolve a run id against the caller's own devices, so an id from another account is not found rather than fetched from wherever it happens to live. The rule that needed stating: the empty account is never a group. Devices nobody has signed in on are unrelated devices that share the absence of an owner, and matching on "" would let any anonymous device read every other one's runs. Tested, along with sibling-device access working and cross-account access not. App side: authorization code with PKCE. The app is a public client - anything compiled into an APK can be read out with unzip and strings - and the redirect returns through a custom URI scheme that any app on the device may register, so an intercepted code is a real risk. PKCE makes a stolen code worthless: it can only be exchanged by presenting a verifier that never left the process. A callback whose state does not match is refused before the code is spent and before any network call, since that is exactly how someone gets a victim to complete the attacker's sign-in. Nothing from the IdP is retained. The ID token is used once to prove who is signing in and then discarded; the device credential authenticates everything afterwards. No access tokens to store, no refresh tokens to rotate. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
34 lines
1.2 KiB
Go
34 lines
1.2 KiB
Go
// SPDX-FileCopyrightText: 2026 Echolot contributors
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
package store
|
|
|
|
import "testing"
|
|
|
|
// The empty account must never match. Devices nobody has signed in on are not a group — they are
|
|
// unrelated devices that share the absence of an owner — and treating that as an account would
|
|
// let any anonymous device read every other anonymous device's runs.
|
|
func TestTheEmptyAccountIsNotAGroup(t *testing.T) {
|
|
s, err := Open(t.TempDir())
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
for _, id := range []string{"anon-1", "anon-2"} {
|
|
s.data.Devices = append(s.data.Devices, Device{ID: id})
|
|
}
|
|
s.data.Devices = append(s.data.Devices,
|
|
Device{ID: "mine-1", AccountID: "iss#me"},
|
|
Device{ID: "mine-2", AccountID: "iss#me"},
|
|
Device{ID: "theirs", AccountID: "iss#them"})
|
|
|
|
if got := s.DeviceIDsForAccount(""); len(got) != 0 {
|
|
t.Fatalf("the empty account matched %v", got)
|
|
}
|
|
if got := s.DeviceIDsForAccount("iss#me"); len(got) != 2 {
|
|
t.Fatalf("account has %v, want both of its devices", got)
|
|
}
|
|
if got := s.DeviceIDsForAccount("iss#them"); len(got) != 1 || got[0] != "theirs" {
|
|
t.Fatalf("wrong devices for the other account: %v", got)
|
|
}
|
|
}
|