Skip to content

Trust Tokens - Remember this computer for X days 2FA#46

Merged
WinterSolstice8 merged 1 commit into
LandSandBoat:mainfrom
9001-Solutions:9001/trust-tokens
Feb 11, 2026
Merged

Trust Tokens - Remember this computer for X days 2FA#46
WinterSolstice8 merged 1 commit into
LandSandBoat:mainfrom
9001-Solutions:9001/trust-tokens

Conversation

@9001-Sols

@9001-Sols 9001-Sols commented Feb 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds client-side support for the server's 2FA trust token feature. When a user checks "Trust this computer" during login with a valid OTP, the server issues a 30-day trust token. On subsequent logins, the token is sent automatically so the user can skip OTP entry.

Changes

  • Trust token persistence (trust_token.cpp/h): Load, save, and remove tokens per server+username pair. Tokens are stored DPAPI-encrypted in %APPDATA%\xiloader\trust_tokens.dat.
  • Login flow (network.cpp, command_handler.h): Send trust_token and trust_this_computer fields with login requests. On successful login, save any server-issued token. On TOTP removal, clear the local token.
  • Dynamic trust indicator (menus.h): Login form reactively checks for a saved trust token as the user types their username. When trusted: shows green "Computer is trusted" text, marks OTP as optional, hides the trust checkbox, and lets Enter on password submit directly.
  • Revoke trust (menus.h, network.cpp): New "Revoke Computer Trust" option in the 2FA submenu to delete a saved token locally.
  • "Trust this computer" checkbox + CLI flag (main.cpp): New --trust CLI arg and trust_this_computer JSON config option.
  • Bug fix (main.cpp): Fix polcorecmd construction - was doing pointer arithmetic (const char* + uint16_t) instead of string concatenation since the JSON rewrite changed port types from std::string to uint16_t.

Test plan

  • Login with OTP + "Trust this computer" checked - confirm token saved, "trusted" message shown
  • Re-login with same username - confirm trust indicator appears, OTP skippable, Enter on password submits
  • Login with untrusted username - confirm normal OTP + checkbox flow
  • Revoke trust via 2FA menu - confirm token deleted, indicator gone on next login
  • Autologin (--user/--pass) with saved trust token - confirm token sent automatically
  • Verify polcorecmd now contains correct port string (no garbage)

Dependencies

LandSandBoat/server#9418

New [ ] Trust this computer option

image

Successful login with Trust this computer checked (specifies how long it is trusted for, server driven, falls back to 30 days)

image

Example of a trusted computer (Dynamically updates when username changes)

image

Bogus Token Auto Revoke

image

Revoke Trust option

image

@9001-Sols 9001-Sols changed the title Trust Tokens Trust Tokens - Remember this computer for 30 days 2FA Feb 9, 2026
Comment thread src/main.cpp Outdated
std::string g_OtpCode = ""; // The OTP code the user input
char g_SessionHash[16] = {}; // Session hash sent from auth
std::string g_Email = ""; // Email, currently unused
std::array<uint8_t, 3> g_VersionNumber = { 2, 0, 1 }; // xiloader version number sent to auth server. Must be x.x.x with single characters for 'x'. Remember to also change in xiloader.rc.in

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm guessing I'll need to bump this, but wanted to hear from somebody first on whether it should be a major, minor, or patch bump

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make a bump version commit to 2.1.0 like this commit 97990c5
(and don't forget the xiloader.rc like I did for 2.0.0)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bumped!

@9001-Sols 9001-Sols force-pushed the 9001/trust-tokens branch 2 times, most recently from 27b7d59 to e66697f Compare February 9, 2026 23:01
@9001-Sols 9001-Sols changed the title Trust Tokens - Remember this computer for 30 days 2FA Trust Tokens - Remember this computer for X days 2FA Feb 9, 2026
@9001-Sols 9001-Sols marked this pull request as ready for review February 9, 2026 23:46
@WinterSolstice8

Copy link
Copy Markdown
Contributor

I have pulled this down and tested it, it works as advertised (even on linux)

@WinterSolstice8 WinterSolstice8 merged commit 1a93e57 into LandSandBoat:main Feb 11, 2026
1 check passed
@9001-Sols 9001-Sols deleted the 9001/trust-tokens branch February 11, 2026 17:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants