Persist Snapmaker cloud login across restarts (secure token store + startup race fix)#479
Open
PGMacDesign wants to merge 2 commits into
Open
Persist Snapmaker cloud login across restarts (secure token store + startup race fix)#479PGMacDesign wants to merge 2 commits into
PGMacDesign wants to merge 2 commits into
Conversation
Snapmaker cloud login was not persisted on Linux/AppImage (and elsewhere): every restart forced a fresh OAuth login. Persist the session so it survives restarts, revalidating the stored token on startup. - Store only the bearer token, and only in the OS secret store via wxSecretStore (libsecret / Credential Manager / Keychain) -- never in plaintext config. If no secret service is available the token is not persisted (falls back to the prior re-login behaviour) rather than written insecurely. Guarded with wxUSE_SECRETSTORE so toolchains without it (e.g. MinGW) still compile. - On startup, revalidate the token against the accounts/current endpoint and re-fetch the profile from the server, restoring the session; clear the stored token on failure or explicit logout. No user data is written to disk. Addresses Snapmaker#116, Snapmaker#226. Builds on the approach proposed in Snapmaker#266, hardened to keep the token out of plaintext on disk.
The persisted session is revalidated asynchronously at startup. That can complete before the Flutter home page subscribes to login-state updates, in which case the one-shot user_login_notify() push reaches an empty subscriber list and is lost -- leaving the UI showing 'logged out' despite a valid, restored token. Make sw_SubscribeUserLoginState push the current login state immediately when the user is already logged in at subscribe time. This closes the race in both orderings: restore-before-subscribe is covered by the immediate push here, and restore-after-subscribe by the existing notify() path.
Author
|
@coderabbitai review |
This was referenced Jun 14, 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.

Description
Snapmaker cloud login was not persisted across restarts on Linux (AppImage/Flatpak) and elsewhere — every launch forced a fresh OAuth login. This PR persists the session securely and restores it on startup, with a fix for a startup race that could otherwise leave the UI showing "logged out" despite a valid restored token.
Fixes #116
Fixes #226
Builds on the approach proposed in #266, hardened to keep the token out of plaintext on disk.
1. Persist login across restarts via the OS secret store (
GUI_App.cpp/.hpp,WebSMUserLoginDialog.cpp)wxSecretStore(libsecret / Windows Credential Manager / macOS Keychain) — never in plaintext config.wxUSE_SECRETSTOREso toolchains without it (e.g. MinGW) still compile.accounts/currentendpoint and re-fetch the profile from the server, restoring the session. The stored token is cleared on validation failure or explicit logout. No user data is written to disk.2. Push restored login to the web UI on subscribe (
SSWCP.cpp)user_login_notify()push reaches an empty subscriber list and is lost — leaving the UI "logged out" despite a valid token.sw_SubscribeUserLoginStatenow pushes the current login state immediately when the user is already logged in at subscribe time. This closes the race in both orderings (restore-before-subscribe via the immediate push here; restore-after-subscribe via the existing notify path).Security notes
OrcaSlicer.confor any plaintext file.Breaking changes / dependencies: none. Uses
wxSecretStore(already part of wxWidgets), guarded bywxUSE_SECRETSTORE.Screenshots/Recordings/Graphs
🎉 Can confirm Login works + Persists across app close / open 🎉
Linux (Pop! OS / Ubuntu)
Mac
Tests
wxUSE_SECRETSTORE.