Repository navigation
fix(secrets): keep no device token in a plain file in the Flatpak unless the user asks - #260
Merged
Merged
Conversation
…ess the user asks (#249) When no Secret Service answered, secrets.Open fell back to secrets.json with only a log line, while ADR-0016, ADR-0031 and the README say the token goes to the keyring unless FROSTNOTES_SECRETS=file is set; the pairing probe then passed on the file and the user was not told. ADR-0045 settles it as Frostmail's ADR-0046 does: in the Flatpak, notesd keeps no plain file, and its store fails every Get, Set and Delete with an error that wraps ErrNoKeyring (never ErrNotFound, which sync reads as a revoked token) and names the flatpak override; the pairing probe fails first. Outside the Flatpak the fallback stays, with its warning. A secrets.json already there stays untouched until a Secret Service answers, then moves in as before. secrets.Options (NoFallback, Hint) and OptionsFor(config.InFlatpak) pick the behavior; TestOpenInTheFlatpakKeepsNoFile fails without it.
bketelsen
approved these changes
Nov 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #249. When no Secret Service answered on the session bus,
secrets.Openreturned the file store (secrets.jsonin notesd's data directory) and only logged a warning. ADR-0016, ADR-0031 and the README say the token goes to the keyring unlessFROSTNOTES_SECRETS=fileis set. On such a desktop the pairing probe passed on the file, and the user was not told.The new ADR-0045 decides it the way Frostmail's ADR-0046 does, so the suite's apps behave alike:
config.InFlatpak), withFROSTNOTES_SECRETSunset and no Secret Service, notesd keeps no plain file. It still starts and serves notes. Its secret store fails everyGet,SetandDeletewith an error that wrapsErrNoKeyringand namesflatpak override --user --env=FROSTNOTES_SECRETS=file org.frostyard.Frostnotes.ErrNotFound, which sync reads as a revoked token. A device paired on the old fallback keeps its pairing, and sync reports the error with the hint.sync.pairanswers "this device cannot keep a hub token: …" with the hint, before the hub hears of the device.secrets.jsonthat is already there stays untouched. When a Secret Service answers on a later start, its tokens move in, as before.FROSTNOTES_SECRETS=filestill picks the file in both cases.Code:
secrets.Options{NoFallback, Hint}, withHostOptions(),FlatpakOptions()andOptionsFor(inFlatpak).Open(ctx, file, log, opts).noKeyringstore.ErrNoKeyringnow reads "no keyring can keep the token". Its 3 existing uses (no default collection) add the hint for where the process runs.cmd/notesdpassesOptionsFor(config.InFlatpak(os.Getenv)).Docs: ADR-0045; the status lines of ADR-0016 and ADR-0031 say they are amended by it; the README's Remove section;
docs/design/sync.mdandoverview.md; and the comment ofpackaging/flatpak/smoke-test.sh. The smoke test runs as the Flatpak with no session bus and pairs nothing, so it still passes.Closes #249
Risk paths
risk:high: this PR touchesinternal/secrets/open.go,secretservice.go,secretservice_test.goand the newoptions.go,options_test.goandnokeyring.go. All are matched byinternal/secrets/**(L1). Why it is safe:FROSTNOTES_SECRETS=filebehave as before.TestOpenPicksAndMigratesstill holds them.ErrNotFound, so no pairing is dropped and no token is lost.TestOpenInTheFlatpakKeepsNoFilechecks all 3 operations and that the file's bytes are unchanged, then checks that the token moves into the Secret Service once one answers. It fails without the change.TestOpenInTheFlatpakAllowsExplicitFileandTestOptionsForcover the override and the choice of options.packaging/flatpak/smoke-test.shchanges only in a comment and is not in the risk list.Checks
make verify(withBASE=origin/main): passed locally.go test ./internal/secrets/ ./internal/syncer/ ./cmd/...: passed.TestOpenInTheFlatpakKeepsNoFilefailed with theNoFallbackcheck removed.