[PR #3769] [MERGED] Launcher: keep Microsoft sign-ins on Linux desktops that set GTK_USE_PORTAL, and say when the keychain doesn't #5205

Closed
opened 2026-11-03 05:10:58 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/3769
Author: @ludovic111
Created: 10/29/2026
Status: ✅ Merged
Merged: 10/29/2026
Merged by: @ludovic111

Base: main ← Head: fix/launcher-keychain-portal


📝 Commits (1)

  • 7db3ecb Launcher: keep Microsoft sign-ins on Linux desktops that set GTK_USE_PORTAL, and say when the keychain doesn't

📊 Changes

5 files changed (+129 additions, -19 deletions)

View changed files

📝 launcher/src/account.rs (+66 -6)
📝 launcher/src/account/tests.rs (+40 -0)
📝 launcher/src/backend.rs (+6 -2)
📝 launcher/src/cli.rs (+5 -2)
📝 launcher/src/main.rs (+12 -9)

📄 Description

🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself.

Part of #3249 and #3711: the launcher forgets the Microsoft sign-in when it reopens.

The cause on Linux (confirmed here, from Senjin's lead in #3249)

Senjin's agent found and reproduced it on Garuda/KDE. I checked each step against the libraries this launcher builds with (Cargo.lock) and the portal's public docs:

  • oo7 0.5.0 (Keyring::new → new_inner) uses its file backend whenever ashpd::is_sandboxed() is true. Note that oo7 0.5.0 depends on ashpd 0.12.3, not 0.11.1.
  • ashpd 0.12.3 is_sandboxed() returns true for /.flatpak-info, a Snap cgroup, or GTK_USE_PORTAL=1. Many KDE sessions export that variable for every app.
  • Where the file goes: outside a sandbox, oo7 puts it at $XDG_DATA_HOME/keyrings/default.keyring, i.e. ~/.local/share/keyrings/, the folder GNOME Keyring keeps its own keyrings in. It opens the file with a key from the Secret portal's RetrieveSecret.
  • Secret portal docs: the master secret "is unique per application". For an app outside a sandbox, the portal takes the app id from its systemd unit, and only app-… units give one (systemd: desktop environments, xdg-desktop-portal #581). A launcher started from the menu runs in such a unit; one started from a terminal gets an empty id.
  • The result: two starts get two different keys for the same file. In the start whose key doesn't match, the keychain probe fails, store() quietly keeps secrets in memory, and the player is "signed out when reopened".

I couldn't run it on a Linux desktop here: no desktop with a portal is available to me. Senjin's runtime check matches every step above. With GTK_USE_PORTAL unset, the sign-in stayed across menu and terminal starts.

The fix

  1. Linux and FreeBSD, outside Flatpak (/.flatpak-info) and Snap ($SNAP): the launcher opens the Secret Service directly (oo7's dbus::Service and its default collection), so GTK_USE_PORTAL no longer moves the secrets into the per-app file. Inside Flatpak and Snap nothing changes, since the portal's file is the right place there.
  2. When the keychain doesn't open: Settings (and account sign-in in the terminal) now says why after the existing line. It reads "No keychain available: … The keychain said: ", instead of only "No keychain available".
  3. A renewed sign-in the keychain refuses: before, account::launch ignored a failed save (let _ = store.set(…)). Now the game still starts, and the player sees "'s renewed sign-in couldn't be saved in the keychain (): you may have to sign in again next time." It shows in the window's message, and on stderr for play.

Never a plaintext fallback: secrets are kept by the system keychain or only in memory for the run, as before. The owner gate is unchanged.

Still open

These reports aren't explained by this PR, and I'm not guessing at them:

  • Windows (#3249, PickledOnion467): d3grando's agent couldn't reproduce on Windows 11 with 0.2.21/0.2.22; the account and its Credential Manager secret survived restarts and a self-update.
  • Signed out after about 30 minutes (#3711, Chernobyl07), and "keeps me logged in but says otherwise" (#3711, czechlover, Void/Hyprland). If a failed save is behind them, part 3 now says so on screen.
  • Steam Deck Gaming Mode (#3249): probably no unlocked Secret Service there. The launcher still keeps the sign-in only for the run, but part 2 now shows the keychain's own error, which the reporters can send us.

Tests

  • a_renewed_sign_in_the_keychain_refuses_still_plays_and_says_so: a keychain that reads but refuses writes.
    • The game still gets its renewed session.
    • The pass and take_unsaved() carry the message, once.
    • Nothing is said when there was nothing to save.
  • Checked by hand on macOS with HORIZON_NO_KEYCHAIN=1 and an account: Settings shows "No keychain available: you are signed in until the launcher closes, then you will have to sign in again. The keychain said: HORIZON_NO_KEYCHAIN is set."
  • The Linux store isn't compiled on macOS. The launcher matrix's Linux build compiles it.

pr_ready (tools/pr_ready.py --quick on ludovics-mac-mini, against origin/main at a49118196, 2 min 21 s)

Check Result
Scope ✅ 5 files, +129 −19
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 416 passed (2 min 12 s)
rustfmt ➖ no Rust change
clippy ➖ no Rust change
tests ➖ no crate touched
doc tests ➖ no crate touched
content root tests ➖ content root untouched
tokens.css up to date ➖ theme untouched
launcher rustfmt ✅ (2 s)
launcher clippy ✅ (1 s)
launcher tests ✅ 273 passed (5 s)
Parity ➖ 1 affected, to run in CI (--quick): lan_integration
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/3769 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/29/2026 **Status:** ✅ Merged **Merged:** 10/29/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/launcher-keychain-portal` --- ### 📝 Commits (1) - [`7db3ecb`](https://github.com/horizon-rust/horizon/commit/7db3ecb67f457ec0ad62e5b13422614d88c5a147) Launcher: keep Microsoft sign-ins on Linux desktops that set GTK_USE_PORTAL, and say when the keychain doesn't ### 📊 Changes **5 files changed** (+129 additions, -19 deletions) <details> <summary>View changed files</summary> 📝 `launcher/src/account.rs` (+66 -6) 📝 `launcher/src/account/tests.rs` (+40 -0) 📝 `launcher/src/backend.rs` (+6 -2) 📝 `launcher/src/cli.rs` (+5 -2) 📝 `launcher/src/main.rs` (+12 -9) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. Part of #3249 and #3711: the launcher forgets the Microsoft sign-in when it reopens. ### The cause on Linux (confirmed here, from Senjin's lead in #3249) Senjin's agent found and reproduced it on Garuda/KDE. I checked each step against the libraries this launcher builds with (`Cargo.lock`) and the portal's public docs: - **oo7 0.5.0** (`Keyring::new` → `new_inner`) uses its file backend whenever `ashpd::is_sandboxed()` is true. Note that oo7 0.5.0 depends on **ashpd 0.12.3**, not 0.11.1. - **ashpd 0.12.3** `is_sandboxed()` returns true for `/.flatpak-info`, a Snap cgroup, **or `GTK_USE_PORTAL=1`**. Many KDE sessions export that variable for every app. - **Where the file goes:** outside a sandbox, oo7 puts it at `$XDG_DATA_HOME/keyrings/default.keyring`, i.e. `~/.local/share/keyrings/`, the folder GNOME Keyring keeps its own keyrings in. It opens the file with a key from the Secret portal's `RetrieveSecret`. - **Secret portal docs:** the master secret "is unique per application". For an app outside a sandbox, the portal takes the app id from its systemd unit, and only `app-…` units give one ([systemd: desktop environments](https://systemd.io/DESKTOP_ENVIRONMENTS/), [xdg-desktop-portal #581](https://github.com/flatpak/xdg-desktop-portal/pull/581)). A launcher started from the menu runs in such a unit; one started from a terminal gets an empty id. - **The result:** two starts get two different keys for the same file. In the start whose key doesn't match, the keychain probe fails, `store()` quietly keeps secrets in memory, and the player is "signed out when reopened". I couldn't run it on a Linux desktop here: no desktop with a portal is available to me. Senjin's runtime check matches every step above. With `GTK_USE_PORTAL` unset, the sign-in stayed across menu and terminal starts. ### The fix 1. **Linux and FreeBSD, outside Flatpak (`/.flatpak-info`) and Snap (`$SNAP`):** the launcher opens the Secret Service directly (oo7's `dbus::Service` and its default collection), so `GTK_USE_PORTAL` no longer moves the secrets into the per-app file. Inside Flatpak and Snap nothing changes, since the portal's file is the right place there. 2. **When the keychain doesn't open:** Settings (and `account sign-in` in the terminal) now says why after the existing line. It reads "No keychain available: … The keychain said: <its error>", instead of only "No keychain available". 3. **A renewed sign-in the keychain refuses:** before, `account::launch` ignored a failed save (`let _ = store.set(…)`). Now the game still starts, and the player sees "<name>'s renewed sign-in couldn't be saved in the keychain (<error>): you may have to sign in again next time." It shows in the window's message, and on stderr for `play`. Never a plaintext fallback: secrets are kept by the system keychain or only in memory for the run, as before. The owner gate is unchanged. ### Still open These reports aren't explained by this PR, and I'm not guessing at them: - **Windows** (#3249, PickledOnion467): d3grando's agent couldn't reproduce on Windows 11 with 0.2.21/0.2.22; the account and its Credential Manager secret survived restarts and a self-update. - **Signed out after about 30 minutes** (#3711, Chernobyl07), and **"keeps me logged in but says otherwise"** (#3711, czechlover, Void/Hyprland). If a failed save is behind them, part 3 now says so on screen. - **Steam Deck Gaming Mode** (#3249): probably no unlocked Secret Service there. The launcher still keeps the sign-in only for the run, but part 2 now shows the keychain's own error, which the reporters can send us. ### Tests - `a_renewed_sign_in_the_keychain_refuses_still_plays_and_says_so`: a keychain that reads but refuses writes. - The game still gets its renewed session. - The pass and `take_unsaved()` carry the message, once. - Nothing is said when there was nothing to save. - **Checked by hand on macOS** with `HORIZON_NO_KEYCHAIN=1` and an account: Settings shows "No keychain available: you are signed in until the launcher closes, then you will have to sign in again. The keychain said: HORIZON_NO_KEYCHAIN is set." - **The Linux store isn't compiled on macOS.** The launcher matrix's Linux build compiles it. **pr_ready** (`tools/pr_ready.py --quick` on ludovics-mac-mini, against origin/main at a49118196, 2 min 21 s) | Check | Result | | --- | --- | | Scope | ✅ 5 files, +129 −19 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 416 passed (2 min 12 s) | | rustfmt | ➖ no Rust change | | clippy | ➖ no Rust change | | tests | ➖ no crate touched | | doc tests | ➖ no crate touched | | content root tests | ➖ content root untouched | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ✅ (2 s) | | launcher clippy | ✅ (1 s) | | launcher tests | ✅ 273 passed (5 s) | | Parity | ➖ 1 affected, to run in CI (--quick): lan_integration | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:10:58 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#5205
No description provided.