Skip to content

PS-22014: Modernize OAuth2 with async/await and strict concurrency - #47

Draft
DominikPalo wants to merge 12 commits into
mainfrom
feature/PS-22014-async-await
Draft

DominikPalo wants to merge 12 commits into
mainfrom
feature/PS-22014-async-await

Conversation

@DominikPalo

@DominikPalo DominikPalo commented Sep 10, 2026 •

Copy link
Copy Markdown
Member

Summary

Modernizes the OAuth2 package around Swift concurrency. This is an intentional, breaking API redesign: the legacy callback/subclass architecture and non-SPM project definitions are removed in favor of a Swift Package Manager-only library centered on an async/await OAuth2Client actor.

Implements the first phase of PS-22014: replace the closure-based API, use modern Swift language features, improve maintainability, and establish comprehensive deterministic unit coverage.

What changed

  • Replaced the legacy flow subclasses, callbacks, and global actor with a per-client OAuth2Client actor and explicit Sendable configuration, credential, token, response, and error models.
  • Added async interfaces for transport, credential persistence, clock/randomness, and interactive authorization; OAuth2AuthorizationPresenter is isolated to MainActor, while token and network work remain safe for background callers.
  • Added OAuth2ResourceClient for concurrent protected-resource requests. It performs generation-aware 401 recovery, coalesces recovery work, and makes at most one retry—never triggering interactive authorization itself.
  • Implemented cancellation-aware single-flight authorization and refresh flows, serialized refresh-token mutations, and revision checks that prevent late network or persistence results from restoring cleared/replaced credentials.
  • Preserved OAuth behaviors through composable async flows: authorization code with PKCE, client credentials (including Reddit variant), refresh and token exchange, device authorization polling, dynamic client registration, password, and implicit grants.
  • Replaced SwiftKeychain with a queue-isolated Security-framework credential store; removed the semaphore and logging dependencies.
  • Removed legacy Xcode/workspace, CocoaPods, and Travis CI definitions. Swift Package Manager is now the only supported package definition.
  • Raised the baseline to Swift 5.10 and enabled complete strict-concurrency checking. GitHub Actions builds with Xcode 15.4 in Swift 5 mode and Xcode 16.2 in both Swift 5 and Swift 6 language modes, treating warnings as errors.
  • Reworked the README, added an async/await migration guide, and added focused concurrency tests covering coalescing, cancellation, token rotation, stale-operation protection, device polling, authorization redirect validation, dynamic registration, and 401 recovery.

Breaking changes

  • The public closure-based and subclass APIs have been removed; consumers must migrate to OAuth2Client and OAuth2ResourceClient.
  • Minimum supported platforms are now macOS 12, iOS 15, tvOS 15, and watchOS 8.
  • Swift Package Manager is the supported integration method.

Migration guidance and examples are available in Docs/ASYNC_AWAIT_MIGRATION.md and the updated README.

Scope notes

This PR does not add DPoP support or a replacement logging API; those remain follow-up modernization work from the Jira epic.

Validation

  • swift test — 26 tests passed locally.
  • CI runs strict-concurrency builds and tests across Swift 5.10, a newer Swift 5 compiler, and Swift 6 language mode.

@DominikPalo DominikPalo changed the title feature/PS 22014 async await PS-22014: Modernize OAuth2 with async/await and strict concurrency Sep 10, 2026
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