Skip to content

chore(oauth): upgrade oauth2 to 5 - #618

Draft
hogan-yuan wants to merge 3 commits into
fix/oauth-revoke-race-java-closefrom
chore/oauth2-v5
Draft

hogan-yuan wants to merge 3 commits into
fix/oauth-revoke-race-java-closefrom
chore/oauth2-v5

Conversation

@hogan-yuan

Copy link
Copy Markdown
Member

Summary

Carries #615 by @Tickwhiz forward. That PR's branch does not allow maintainer edits, and it conflicts with #617, so it is ported here with the original authorship kept on the main commit. Stacked on #617. The base will be switched to main (via rebase) once #617 is merged.

From #615

  • oauth2 4.4 → 5. The typestate BasicClient is aliased as LongbridgeClient, and the TokenResponse bound is updated.

  • Token requests go through a reqwest 0.12 client with redirect::Policy::none(), which preserves the old transport's refusal to follow redirects.

  • Regression tests on loopback servers cover:

    • the authorization, denial and CSRF paths
    • refresh rotation and omission
    • HTTP and storage failures, and reauthorization
    • redirect refusal and default expiry
    • blocking cached-token loading
    • endpoint selection, run in isolated child processes

    A cfg(test) task-local overrides the endpoint for these tests.

  • The separate reqwest 0.11 / hyper 0.14 / rustls 0.21 chain is gone. cargo tree now shows a single reqwest 0.12.28, and no hyper 0.14.

Adaptations to #617

Review notes

  • TLS: the workspace reqwest has default-features = false, and the feature graph only enables rustls-tls-webpki-roots. OAuth therefore stays on rustls with webpki roots, as before, and does not switch to native-tls.
  • Endpoint-selection child processes: LONGBRIDGE_REGION is honored by longbridge_geo::is_cn, so they make no network calls.
  • Hang guard: the loopback flows' 5 s hang guard is raised to 30 s, so slow CI runners don't fail spuriously. This is a separate commit.

Test plan

  • cargo test -p longbridge-oauth (47 passed, 1 ignored child) and --all-features (48 + 3 doctests)
  • cargo clippy -p longbridge-oauth --all-features --all-targets -- -D warnings
  • cargo check of longbridge, longbridge-c, longbridge-java, longbridge-python, longbridge-nodejs (all features)
  • cargo test -p longbridge --lib (81)
  • cargo +nightly fmt --all

Closes #615 once merged.

🤖 Generated with Claude Code

Tickwhiz and others added 3 commits November 4, 2026 19:30
Ports #615 (by @Tickwhiz) onto #617:
- oauth2 4.4 -> 5: typestate BasicClient (LongbridgeClient alias),
  TokenResponse bound, async requests through a reqwest 0.12 client that
  refuses redirects like the previous transport
- revoke_with takes any oauth2::AsyncHttpClient; the #617 timeout and
  lock-holding tests use Fn clients as oauth2 5 requires
- loopback regression tests for authorization, denial, CSRF, refresh
  rotation/omission, HTTP and storage failures, reauthorization,
  redirect refusal, default expiry, blocking cached-token loading and
  endpoint selection (task-local test endpoint override)
- the separate reqwest 0.11 / hyper 0.14 / rustls 0.21 chain is gone
The 5s per-flow timeout only guards against hangs; 30s avoids spurious
failures on slow CI runners.
- CI runs clippy (all targets, -D warnings) and tests for
  longbridge-oauth; only the longbridge crate was tested, so the loopback
  regression suite never ran in CI
- the endpoint-selection child skips instead of panicking when run
  without its parent (e.g. --include-ignored)
- outside TEST_OAUTH_BASE_URL.scope, tests fail closed instead of
  silently reaching the real OAuth endpoints; the revoke-without-token
  test no longer probes the region over the network
- the reqwest client has connect/total timeouts, so the authorization
  code exchange is bounded too

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants