[PR #2879] [MERGED] Keep long Microsoft sign-in secrets in several keychain items #4665

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

📋 Pull Request Information

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

Base: main ← Head: fix/keychain-long-secrets


📝 Commits (1)

  • 8d2b298 Keep long Microsoft sign-in secrets in several keychain items

📊 Changes

3 files changed (+117 additions, -12 deletions)

View changed files

📝 docs/microsoft-account.md (+2 -1)
📝 launcher/src/account.rs (+85 -11)
📝 launcher/src/account/tests.rs (+30 -0)

📄 Description

🤖 Opened by leifiyoo's AI agent (Claude Code, Haiku 5.5), not by leifiyoo directly.

Problem

Signing in with a Microsoft account on Windows fails at the last step. The launcher shows
Attribute 'password encoded as UTF-16' is longer than platform limit of 2560 chars under "Microsoft account".

Cause

The sign-in's secrets (the Microsoft refresh token and the Minecraft token, as one JSON value) go to the
keychain as one item. Windows Credential Manager takes at most 2560 bytes per item, and the value is longer,
so the store refuses it.

Fix

On macOS and Windows the secret is split over the items <uuid>, <uuid>.1, <uuid>.2... of at most 1000 UTF-8
bytes each (under 2560 bytes of UTF-16). Reads join the pieces, a write removes the leftovers of a longer
secret, and sign-out removes all of them. Existing single items keep working. Linux (Secret Service) is unchanged.
docs/microsoft-account.md describes the storage.

Tests

  • cargo test --locked in launcher/: 190 + 43 + 6 + 1 passed, 0 failed.
  • New unit test long_secrets_split_into_keychain_sized_pieces (multibyte cuts, piece sizes).
  • New test system_keychain_keeps_long_secrets (#[ignore], cargo test --locked system_keychain -- --ignored):
    writes a 3000-character secret to the real Windows Credential Manager under a test key and removes it.
    On the old code it fails with the error above; with this change it passes.
  • cargo fmt --check and cargo clippy --locked --all-targets -- -D warnings are clean.

Checked on Windows 11 only. The macOS Keychain uses the same code path but was not run here.

🤖 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/2879 **Author:** [@leifiyoo](https://github.com/leifiyoo) **Created:** 10/27/2026 **Status:** ✅ Merged **Merged:** 10/27/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/keychain-long-secrets` --- ### 📝 Commits (1) - [`8d2b298`](https://github.com/horizon-rust/horizon/commit/8d2b2982534d6422dedd7257f3dbae0462e400fd) Keep long Microsoft sign-in secrets in several keychain items ### 📊 Changes **3 files changed** (+117 additions, -12 deletions) <details> <summary>View changed files</summary> 📝 `docs/microsoft-account.md` (+2 -1) 📝 `launcher/src/account.rs` (+85 -11) 📝 `launcher/src/account/tests.rs` (+30 -0) </details> ### 📄 Description > 🤖 Opened by leifiyoo's AI agent (Claude Code, Haiku 5.5), not by leifiyoo directly. ## Problem Signing in with a Microsoft account on Windows fails at the last step. The launcher shows `Attribute 'password encoded as UTF-16' is longer than platform limit of 2560 chars` under "Microsoft account". ## Cause The sign-in's secrets (the Microsoft refresh token and the Minecraft token, as one JSON value) go to the keychain as one item. Windows Credential Manager takes at most 2560 bytes per item, and the value is longer, so the store refuses it. ## Fix On macOS and Windows the secret is split over the items `<uuid>`, `<uuid>.1`, `<uuid>.2`... of at most 1000 UTF-8 bytes each (under 2560 bytes of UTF-16). Reads join the pieces, a write removes the leftovers of a longer secret, and sign-out removes all of them. Existing single items keep working. Linux (Secret Service) is unchanged. `docs/microsoft-account.md` describes the storage. ## Tests - `cargo test --locked` in `launcher/`: 190 + 43 + 6 + 1 passed, 0 failed. - New unit test `long_secrets_split_into_keychain_sized_pieces` (multibyte cuts, piece sizes). - New test `system_keychain_keeps_long_secrets` (`#[ignore]`, `cargo test --locked system_keychain -- --ignored`): writes a 3000-character secret to the real Windows Credential Manager under a test key and removes it. On the old code it fails with the error above; with this change it passes. - `cargo fmt --check` and `cargo clippy --locked --all-targets -- -D warnings` are clean. Checked on Windows 11 only. The macOS Keychain uses the same code path but was not run here. 🤖 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:07:03 +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#4665
No description provided.