Skip to content

Compute the anti-abuse hash on Authress calls; stamp User-Agent everywhere - #5

Merged
wparad merged 2 commits into
mainfrom
claude/anti-abuse-hash-user-agent-aa8qql
Aug 14, 2026
Merged

Compute the anti-abuse hash on Authress calls; stamp User-Agent everywhere#5
wparad merged 2 commits into
mainfrom
claude/anti-abuse-hash-user-agent-aa8qql

Conversation

@wparad

@wparad wparad commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Summary

  • The Kotlin port of the Authress login SDK (AuthressLoginClient/JwtManager) never sent an antiAbuseHash on the /authentication or /authentication/{id}/tokens calls, so Authress was rejecting them. Ported the SDK's proof-of-work algorithm — search a fineTuner until base64url(SHA-256("timestamp;fineTuner;values")) starts with "00", formatted as v2;timestamp;fineTuner;hash — into JwtManager.calculateAntiAbuseHash, and wired it into both request bodies.
  • Only the Authress calls carried an identifying header (X-Powered-By), and even those fell back to OkHttp's default User-Agent. The Email API calls had no identifying header at all. Added a UserAgentInterceptor on the shared OkHttpClient in AppContainer so every request — Authress session calls and Email API calls alike — carries a real User-Agent.

Test plan

  • Manual sign-in against the live Authress domain — confirm /authentication no longer rejects for a bad/missing anti-abuse hash
  • Confirm User-Agent is present on both Authress and Email API requests (e.g. via request logging)
  • Could not run a full Gradle build in this environment (no Android SDK), so changes were reviewed manually against the upstream @authress/login-react-native/@authress/login SDK sources for algorithm parity

🤖 Generated with Claude Code

https://claude.ai/code/session_01XRMBgZXVCEVwBuBWapy5J7


Generated by Claude Code

claude added 2 commits August 14, 2026 10:08
…ery request

The login SDK port never sent antiAbuseHash on /authentication or
/authentication/{id}/tokens, so Authress rejected the calls. Added
JwtManager.calculateAntiAbuseHash (the SDK's proof-of-work: search a
fine-tuner until base64url(SHA-256(timestamp;fineTuner;values)) starts
with "00") and wired it into both request bodies.

Also, only the Authress calls carried an identifying header
(X-Powered-By), and even those relied on OkHttp's default User-Agent.
Added a UserAgentInterceptor on the shared OkHttpClient so both the
Authress session client and the Email API client send a real
User-Agent on every request.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XRMBgZXVCEVwBuBWapy5J7
…Logs tab

Compared the Kotlin port against @authress/login (web) call-for-call:

- Fixed a real bug in the antiAbuseHash algorithm: array-valued props (e.g.
  audiences) must stringify as JS would (comma-joined, no brackets) when they
  fall through untouched into the hash's join step — Kotlin's default
  List.toString() produces "[a, b]" instead of "a,b", which would have kept
  producing a hash the backend can't reproduce for any call using array props.
- Expanded authenticate() to accept the same options the web/RN SDKs support
  (tenantLookupIdentifier, inviteId, responseLocation, flowType, scopes,
  audiences, connectionProperties, multiAccount), with the antiAbuseHash prop
  order matching the web SDK's authenticate() exactly.
- Added linkIdentity, getUserProfile, getDevices, and deleteDevice — present
  in the RN SDK but missing from this port; closes the MFA/passkey gap noted
  in todo.md (the Settings UI for device management is still a follow-up).
- Added antiAbuseHash to linkIdentity, matching the web SDK's key order.

Also added an AppLogger (Room-backed) that every Authress call now reports
failures to, and a Settings > Logs tab so a user can review and share
(via the system share sheet) what happened when reporting a problem back
to us, instead of it only ever reaching logcat.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XRMBgZXVCEVwBuBWapy5J7
@wparad
wparad merged commit 85c8a2c into main Aug 14, 2026
2 checks passed
@wparad
wparad deleted the claude/anti-abuse-hash-user-agent-aa8qql branch August 14, 2026 12:09
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