Skip to content

fix(accounts): follow up on the merged accounts pull requests - #2487

Open
houko wants to merge 7 commits into
mainfrom
fix/followup-online-1
Open

houko wants to merge 7 commits into
mainfrom
fix/followup-online-1

Conversation

@houko

@houko houko commented Nov 29, 2026

Copy link
Copy Markdown
Contributor

Follow-up review of the accounts, purchases, achievements and anti-addiction pull requests the merge train landed, as they stand on main.

#2079 and #2224: session lifecycle core

Two attempts at the same SessionDirectory. #2079 merged after #2224 and put back its first draft: Refresh checked the secret and rotated it under two separate locks again, and #2224's absolute expiry, list and revoke test was gone, as was the guide section both PRs added. This PR restores #2224's checkLocked, its test, and the guide section (en and zh), which now says the service's Store, config and HTTP routes do not use the directory yet, and documents ErrSessionExpired and ErrSessionReuse.

#2079 said Fixes #1683, but #1683's acceptance (config fields, Store methods with migrations, GET /v1/sessions and sign out everywhere, expiry checked in checkSession) is not met: the directory is in-memory and unused.

#2076 and #2225: public profiles

Same pattern: #2076 merged after #2225 and reverted it. Users returned profiles in map order, a nil context panicked, and the filter and private copy test and the note's ordering sentence were gone. Restored, with doc comments on the two username errors and a test that 16 concurrent claims of one username leave one owner. #1684 (closed by both) still lacks persistence, a schema migration and HTTP routes.

#2126 and #2127: password policy, password change and unlink

  • ChangePassword hashed the new password with HashPassword, which checks only the maximum, so POST /v1/password accepted a one-character password. It now applies ValidatePassword first, and the service's own check uses the same function.
  • ValidatePassword counted bytes where the service counts characters, so it passed passwords registration refused. It counts characters now.
  • feat(accounts): expose password policy validation #2126's guide sentence was dropped by a later merge. The passwords section now states the rule.

Not fixed here: a password change does not revoke other sessions, and two concurrent unlinks on an account without email can remove both of its identities because Store.UnlinkIdentity does not check the last credential atomically. Both are #1651's scope (still open).

#2128: data export and deletion

GET /v1/me/export and DELETE /v1/me had no tests. The export marshalled Account and Identity, which had no JSON tags, so it wrote ID, Email, Provider instead of the camel-case keys every other route uses, and null for no identities. This PR tags both types (the liveops client already decodes identities case-insensitively, so it is unaffected), documents the document's shape, lists both routes and last_credential in Handler's comment, and tests that the export carries no secrets and that a deleted account can neither refresh nor sign in. The guide's table rows and paragraph a later merge dropped are restored, along with its warning that cloud saves and leaderboards are not erased. #1650 (closed) asked for that erasure, plus tests and docs in cloudsave.md and leaderboard-selfhost.md, and none of it was done.

#2123 and #2240: identity verifiers

Two verifiers for one issue, already merged into one oidc.go by 5ebd0b0. Remaining defects:

  • Each JWKS entry was decoded into map[string]string, so an entry with an array member, such as the x5c and key_ops in Microsoft's and Auth0's key sets, failed to decode and its key was silently dropped. Every token from those issuers was refused. The decoder now reads only the members it uses.
  • identity.ErrInvalidToken was exported but never returned by the verifier. Refusals now wrap it.
  • A new test covers wrong audience and issuer, expiry, not-before, a missing subject, a wrong key, a tampered payload, and a rotated-in key fetched once after the five-minute limit.
  • The PRs left two changelog fragments and two notes. One of each is kept, and the kept note absorbs the other's rejected alternative. The guide says the nonce is not checked.

#2240 said Fixes #1652, but #1652 asks for nonce checks, recorded fixtures and mini program error codes, and there is no nonce check.

#2242: account tokens and offers

The liveops guide section was dropped by a later merge. It is restored in en and zh under In-app purchases, saying how to set PurchasesOptions.AccountToken. BuyOffer had no test; one now checks that the signed offer reaches the store and the subscription is delivered.

#2103: Steam catalog identifiers

  • ProviderSteam was inserted before ProviderMiniGame, changing the value of an existing exported constant. It is appended after it now.
  • The guides said achievements with a Steam ID are dispatched by a Steamworks adapter. Nothing reports catalog IDs to Steam: ServiceFor never picks Steam, and no leaderboard code submits there. They also repeated each section's sentence twice. Both guides (en and zh) now say what the IDs do and to pass them to online/steam.
  • The PR carried two notes and two changelog fragments for one change. One of each is kept.

#2129: anti-addiction age rules

OK as folded by #2473. No changes.

Verification

  • go tool nsgo test ./pkg/online/accounts/... ./pkg/online/liveops/... ./pkg/online/leaderboard/... ./pkg/online/achievements/... ./internal/repocheck/...: 0 failed.
  • go tool nsgo check ./pkg/online/..., go run ./tools/changelog check and bun run verify-notes pass.

Screenshots: None

The merge of #2079 after #2224 put back the first draft of session_lifecycle.go and its test: Refresh checked the secret and rotated it under two separate locks, so two refreshes with one secret could both pass the check, and the absolute expiry, list and revoke test was gone. Restore #2224's checkLocked and test, document the two errors, and restore the guide section both PRs added, saying the service does not use the directory yet.
The merge of #2076 after #2225 put back the first draft of public.go: Users returned profiles in map order again, a nil context panicked, and the filter and private copy test and the note's ordering sentence were gone. Restore them, document the two username errors and add a test that concurrent claims of one username leave exactly one owner.
ChangePassword (#2127) hashed the new password directly with HashPassword, which checks only the maximum length, so a signed-in player could change a password to a single character. It now calls ValidatePassword first, and the service's hashPassword uses it too. ValidatePassword (#2126) counted bytes where the service counts characters, so it passed passwords the service refused; it counts characters now. The guide sentence #2126 added was dropped by a later merge; the passwords section now states the rule.
…deletion

#2128 added GET /v1/me/export and DELETE /v1/me without a test of either. The export marshalled Account and Identity, which had no JSON tags, so it wrote "ID", "Email" and "Provider" where every other route writes camel-case keys, and null for an account without identities. Tag the two types (the liveops client already decodes identities case-insensitively, so it is unaffected), document the document's shape, list both routes and last_credential in Handler's comment, and test that the export carries no secrets and that a deleted account can neither refresh nor sign in. Restore the guide's table rows and paragraph a later merge dropped, keeping its warning that cloud saves and leaderboards are not erased.
…idToken

The OIDC verifier merged from #2123 and #2240 decoded each JWKS entry into a map of strings, so an entry with an array member, such as the x5c and key_ops that Microsoft's and Auth0's key sets carry, failed to decode and its key was silently dropped: every token from those issuers was refused. Decode only the members it needs. Refusals now wrap identity.ErrInvalidToken, which #2240 exported but the merged verifier never returned, and a test covers wrong audience and issuer, expiry, not-before, a missing subject, a wrong key, a tampered payload and a rotated-in key.

The two PRs also left two changelog fragments and two notes for one verifier; keep #2240's, absorbing the other's rejected alternative, and say in the guide that the nonce is not checked.
…ffer

A later merge dropped the In-app purchases section #2242 added to liveops.md in both languages, and BuyOffer had no test. Restore the section under In-app purchases, saying how to set the account token, and test that BuyOffer sends the signed offer to the store and delivers the subscription.
…log guides

#2103 inserted ProviderSteam before ProviderMiniGame, changing the value of an existing exported constant; append it instead. The guides it added said achievements with a Steam ID are dispatched by a Steamworks adapter, but nothing reports catalog IDs to Steam (ServiceFor never picks Steam, no leaderboard code submits there), and repeated each section's sentence twice in both languages; say what the IDs do and how to use them with online/steam. The PR also carried two notes and two changelog fragments for the one change; keep one of each.
@github-actions github-actions Bot added size/M bug Something isn't working documentation Improvements or additions to documentation area/agents pkg/online labels Nov 29, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/agents bug Something isn't working documentation Improvements or additions to documentation pkg/online size/M

Projects

None yet

1 participant