[PR #161] [MERGED] Microsoft account (a): join online-mode servers (session join, RSA, AES/CFB8), skins over HTTPS #2363

Closed
opened 2026-11-02 15:55:20 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

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

Base: main ← Head: feat/msa-online-mode


📝 Commits (7)

  • c663483 WIP: Microsoft account design note and RSA (not wired yet)
  • c8629f3 Protocol: RSA public keys and PKCS#1 encryption, server hash, secrets
  • 89b2ca6 Join online-mode servers with the launcher's account
  • ac97e9c Harness: online-mode login against vanilla's server and a mock session service
  • 6957d74 docs: Minecraft login endpoint
  • 0acd686 rustfmt
  • f38e8cc Skins over HTTPS: fetch textures with ureq (rustls)

📊 Changes

15 files changed (+1728 additions, -68 deletions)

View changed files

📝 Cargo.lock (+382 -0)
📝 crates/horizon-client/Cargo.toml (+2 -0)
➕ crates/horizon-client/src/auth.rs (+343 -0)
📝 crates/horizon-client/src/game.rs (+14 -1)
📝 crates/horizon-client/src/game/net_harness.rs (+6 -1)
📝 crates/horizon-client/src/game/remote.rs (+4 -1)
📝 crates/horizon-client/src/lib.rs (+1 -0)
📝 crates/horizon-client/src/net.rs (+60 -14)
📝 crates/horizon-client/src/skins.rs (+47 -49)
📝 crates/horizon-protocol/Cargo.toml (+3 -0)
📝 crates/horizon-protocol/src/crypto.rs (+79 -2)
📝 crates/horizon-protocol/src/lib.rs (+1 -0)
➕ crates/horizon-protocol/src/rsa.rs (+330 -0)
➕ docs/microsoft-account.md (+187 -0)
➕ tools/test_online_mode_parity.py (+269 -0)

📄 Description

What

Part (a) of Microsoft account support (queue item 4, design note docs/microsoft-account.md): the game joins online-mode servers like vanilla 26.3.

  • horizon-protocol: rsa.rs (X.509 RSA public keys, PKCS#1 v1.5 encryption with OS randomness, Montgomery modpow), crypto::server_hash (vanilla's signed SHA-1 hex digest, new BigInteger(digest).toString(16)), crypto::generate_secret.
  • horizon-client:
    • auth.rs reads the launcher's session file (--session-file PATH / HORIZON_SESSION_FILE). The file must be owner-only and under 2 minutes old, and it is deleted when read, so the token never sits on the command line. It also does the session join through the services discovery document (authlib 10.0.77's MinecraftServicesSessionService.joinServer), with authlib's error mapping. HORIZON_API_DISCOVERY overrides the discovery URL, the same override authlib has as -Dminecraft.api.discovery.host.
    • net.rs answers ClientboundHelloPacket: shared secret, server hash, session join, RSA-wrapped ServerboundKeyPacket, then AES/CFB8 both ways (the AES/CFB8 code was already there). Vanilla's messages: "Failed to log in: Invalid session (Try restarting your game and the launcher)", "…servers unavailable", "…banned", "…Multiplayer is disabled". Connecting screen states follow vanilla: Connecting… → Logging in… → Encrypting… → Joining world….
    • With no account, an online server says: "This server is in online mode. Sign in with your Microsoft account in the Horizon launcher to join it." Offline and LAN play are unchanged.
  • Skins over HTTPS: skins::http_get now uses ureq/rustls. Before this, a skin that wasn't cached couldn't be fetched from https://textures.minecraft.net, so every player on an online server showed the default skin. With it, the real names and skins of online-mode players show.
  • tools/test_online_mode_parity.py (dev only, needs no real account): a mock session service plus vanilla 26.3's own dedicated server in online mode, started with -Dminecraft.api.discovery.host=<mock>.

Why

NEXT-VERSION §1 / FEATURES queue item 4. Players can't reach this yet: it needs a session file, which only the launcher sign-in (next PR) will write. Hence skip-release.

How tested (Mac mini)

  • cargo test -p horizon-protocol: 44 tests pass, plus skins tests including a local HTTP fetch, including:
    • Notch/jeb_/simon server-hash vectors;
    • an RSA round trip with a 1024-bit test key, decrypted with the private exponent and padding checked;
    • an OpenSSL SHA256withRSA signature verified with the key;
    • the existing FIPS-197 and NIST CFB8 vectors.
  • cargo test -p horizon-client auth: 5 tests (session file privacy/age/deletion, field checks, join request body, authlib error mapping, discovery endpoints). Clippy is clean on both crates.
  • tools/test_online_mode_parity.py: 15/15 checks against vanilla 26.3's server.
    • Signed in: the client joins the mock once, the server verifies the same hash it computed itself, the player spawns with chunks, chats, runs /list and leaves, and the session file is deleted. This proves the RSA wrapping, hash and AES/CFB8 against vanilla's code.
    • Rejected token: the client shows "Failed to log in: Invalid session…" and no verify happens.
    • Join the mock forgets: the server sends "Failed to verify username!".
    • No account: the client refuses before any service call.
  • tools/test_dedicated_server_parity.py (offline join regression): passes, 543 transcript lines identical, and the Horizon client checks are ok.

Not in this PR

  • Cape rendering: capes are downloaded but Horizon has no cape layer yet.
  • Launcher sign-in with keychain and session file (part c).
  • Chat signing (part d): on servers with enforce-secure-profile=true whose services can validate keys (the real ones), chat will say "missing profile public key" until (d).
  • Horizon's own dedicated/LAN servers stay offline-mode.

Needs Ludovic

Nothing for this PR. For the whole feature: the Azure app registration and the Mojang Minecraft API access form. The exact steps are in docs/microsoft-account.md ("What Ludovic registers").

🤖 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/161 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/14/2026 **Status:** ✅ Merged **Merged:** 10/14/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `feat/msa-online-mode` --- ### 📝 Commits (7) - [`c663483`](https://github.com/horizon-rust/horizon/commit/c6634830d319da65d43c92c1861074949a95d793) WIP: Microsoft account design note and RSA (not wired yet) - [`c8629f3`](https://github.com/horizon-rust/horizon/commit/c8629f3378fec01fe30c0e32e01e93942f4dcbc5) Protocol: RSA public keys and PKCS#1 encryption, server hash, secrets - [`89b2ca6`](https://github.com/horizon-rust/horizon/commit/89b2ca64a9da151ab8876c28d095a5416658f5ed) Join online-mode servers with the launcher's account - [`ac97e9c`](https://github.com/horizon-rust/horizon/commit/ac97e9c0b9be8f3368a1a645a15a369d827c5204) Harness: online-mode login against vanilla's server and a mock session service - [`6957d74`](https://github.com/horizon-rust/horizon/commit/6957d74742637cbf10e399b64218973b87378f7e) docs: Minecraft login endpoint - [`0acd686`](https://github.com/horizon-rust/horizon/commit/0acd686720c6a02c9c916533856357cd0f7c1e1d) rustfmt - [`f38e8cc`](https://github.com/horizon-rust/horizon/commit/f38e8cc393214658641672f62d0a3797fd4008b9) Skins over HTTPS: fetch textures with ureq (rustls) ### 📊 Changes **15 files changed** (+1728 additions, -68 deletions) <details> <summary>View changed files</summary> 📝 `Cargo.lock` (+382 -0) 📝 `crates/horizon-client/Cargo.toml` (+2 -0) ➕ `crates/horizon-client/src/auth.rs` (+343 -0) 📝 `crates/horizon-client/src/game.rs` (+14 -1) 📝 `crates/horizon-client/src/game/net_harness.rs` (+6 -1) 📝 `crates/horizon-client/src/game/remote.rs` (+4 -1) 📝 `crates/horizon-client/src/lib.rs` (+1 -0) 📝 `crates/horizon-client/src/net.rs` (+60 -14) 📝 `crates/horizon-client/src/skins.rs` (+47 -49) 📝 `crates/horizon-protocol/Cargo.toml` (+3 -0) 📝 `crates/horizon-protocol/src/crypto.rs` (+79 -2) 📝 `crates/horizon-protocol/src/lib.rs` (+1 -0) ➕ `crates/horizon-protocol/src/rsa.rs` (+330 -0) ➕ `docs/microsoft-account.md` (+187 -0) ➕ `tools/test_online_mode_parity.py` (+269 -0) </details> ### 📄 Description ## What Part (a) of Microsoft account support (queue item 4, design note `docs/microsoft-account.md`): the game joins **online-mode** servers like vanilla 26.3. - `horizon-protocol`: `rsa.rs` (X.509 RSA public keys, PKCS#1 v1.5 encryption with OS randomness, Montgomery modpow), `crypto::server_hash` (vanilla's signed SHA-1 hex digest, `new BigInteger(digest).toString(16)`), `crypto::generate_secret`. - `horizon-client`: - `auth.rs` reads the launcher's session file (`--session-file PATH` / `HORIZON_SESSION_FILE`). The file must be owner-only and under 2 minutes old, and it is deleted when read, so the token never sits on the command line. It also does the session `join` through the services discovery document (authlib 10.0.77's `MinecraftServicesSessionService.joinServer`), with authlib's error mapping. `HORIZON_API_DISCOVERY` overrides the discovery URL, the same override authlib has as `-Dminecraft.api.discovery.host`. - `net.rs` answers `ClientboundHelloPacket`: shared secret, server hash, session join, RSA-wrapped `ServerboundKeyPacket`, then AES/CFB8 both ways (the AES/CFB8 code was already there). Vanilla's messages: "Failed to log in: Invalid session (Try restarting your game and the launcher)", "…servers unavailable", "…banned", "…Multiplayer is disabled". Connecting screen states follow vanilla: Connecting… → Logging in… → Encrypting… → Joining world…. - With no account, an online server says: "This server is in online mode. Sign in with your Microsoft account in the Horizon launcher to join it." Offline and LAN play are unchanged. - Skins over HTTPS: `skins::http_get` now uses ureq/rustls. Before this, a skin that wasn't cached couldn't be fetched from `https://textures.minecraft.net`, so every player on an online server showed the default skin. With it, the real names and skins of online-mode players show. - `tools/test_online_mode_parity.py` (dev only, needs no real account): a mock session service plus vanilla 26.3's own dedicated server in online mode, started with `-Dminecraft.api.discovery.host=<mock>`. ## Why NEXT-VERSION §1 / FEATURES queue item 4. Players can't reach this yet: it needs a session file, which only the launcher sign-in (next PR) will write. Hence `skip-release`. ## How tested (Mac mini) - `cargo test -p horizon-protocol`: 44 tests pass, plus `skins` tests including a local HTTP fetch, including: - Notch/jeb_/simon server-hash vectors; - an RSA round trip with a 1024-bit test key, decrypted with the private exponent and padding checked; - an OpenSSL SHA256withRSA signature verified with the key; - the existing FIPS-197 and NIST CFB8 vectors. - `cargo test -p horizon-client auth`: 5 tests (session file privacy/age/deletion, field checks, join request body, authlib error mapping, discovery endpoints). Clippy is clean on both crates. - `tools/test_online_mode_parity.py`: **15/15 checks** against vanilla 26.3's server. - Signed in: the client joins the mock once, the server verifies the same hash it computed itself, the player spawns with chunks, chats, runs /list and leaves, and the session file is deleted. This proves the RSA wrapping, hash and AES/CFB8 against vanilla's code. - Rejected token: the client shows "Failed to log in: Invalid session…" and no verify happens. - Join the mock forgets: the server sends "Failed to verify username!". - No account: the client refuses before any service call. - `tools/test_dedicated_server_parity.py` (offline join regression): passes, 543 transcript lines identical, and the Horizon client checks are ok. ## Not in this PR - Cape rendering: capes are downloaded but Horizon has no cape layer yet. - Launcher sign-in with keychain and session file (part c). - Chat signing (part d): on servers with `enforce-secure-profile=true` whose services can validate keys (the real ones), chat will say "missing profile public key" until (d). - Horizon's own dedicated/LAN servers stay offline-mode. ## Needs Ludovic Nothing for this PR. For the whole feature: the Azure app registration and the Mojang Minecraft API access form. The exact steps are in `docs/microsoft-account.md` ("What Ludovic registers"). 🤖 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-02 15:55:20 +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#2363
No description provided.