Skip to content

feat: Support mandatory server-to-server revocation notifications for SignInWithApple - #4193

Merged
nielsenko merged 4 commits into
serverpod:mainfrom
nielsenko:apple-revocation
Nov 12, 2025
Merged

nielsenko merged 4 commits into
serverpod:mainfrom
nielsenko:apple-revocation

Conversation

@nielsenko

@nielsenko nielsenko commented Nov 12, 2025 •

Copy link
Copy Markdown
Collaborator

Apple Sign In: Server-to-Server Revocation Notifications

This PR implements support for Apple's server-to-server revocation notifications, enabling automatic session revocation when users revoke consent or delete their Apple account.

Closes: #4105
Closes: #3453

Changes

Core Implementation

  • Implemented serverNotificationHandler in AppleIDPUtils to process Apple server-to-server notifications
  • Added automatic session revocation for AppleServerNotificationConsentRevoked and AppleServerNotificationAccountDelete events
  • Added Apple account deletion when receiving AppleServerNotificationAccountDelete notification
  • Refactored route handling with new AppleRevokedNotificationRoute and AppleWebAuthenticationCallbackRoute classes

API Changes

  • BREAKING: AppleIDP constructor now requires TokenManager instead of TokenIssuer
  • BREAKING: AppleIDPUtils constructor now requires TokenManager parameter
  • BREAKING: Removed generic serverNotificationHandler() method - replaced with specific serverNotificationHandler(Session, Request) implementation
  • BREAKING: Removed revokedNotificationHandler() method from AppleIDPUtils
  • Added webAuthenticationCallbackRoute() method to AppleIDP for foreign platform authentication callbacks

Route Structure

  • Refactored routes to use sealed base class _SignInWithAppleRoute
  • AppleRevokedNotificationRoute now handles POST requests for server-to-server notifications
  • Added AppleWebAuthenticationCallbackRoute for GET requests on foreign platforms (Web, Android)

Example Updates

  • Updated example app to demonstrate route setup for both notification and callback routes
  • Added Apple Sign In initialization with service identifier and redirect URI configuration

Fixes

This PR addresses server-to-server notification handling for Apple Sign In as part of the authentication system improvements.

Pre-launch Checklist

  • I read the Contribute page and followed the process outlined there for submitting PRs.
  • This update contains only one single feature or bug fix and nothing else.
  • I read and followed the Dart Style Guide and formatted the code with dart format.
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///), and made sure that the documentation follows the same style as other Serverpod documentation. I checked spelling and grammar.
  • I added new tests to check the change I am making.
  • All existing and new tests are passing.
  • Any breaking changes are documented below.

Breaking changes

TokenManager Requirement

  • AppleIDP factory constructor now requires TokenManager tokenManager instead of TokenIssuer tokenIssuer
  • AppleIDPUtils constructor now requires TokenManager tokenManager parameter
  • Migration: Replace tokenIssuer parameter with tokenManager when creating AppleIDP or AppleIDPUtils instances

Handler Method Changes

  • Removed Handler revokedNotificationHandler() from AppleIDPUtils
  • Removed Handler serverNotificationHandler(FutureOr<void> Function(AppleServerNotification) handler) from AppleIDPUtils
  • Replaced with Future<Result> serverNotificationHandler(Session session, Request req) that directly processes notifications
  • Migration: Use revokedNotificationRoute() on AppleIDP instead of calling utils.revokedNotificationHandler() directly

Route Setup

  • Route mounting now requires separate routes for notification handling and authentication callbacks:
    // Before: No structured route support
    
    // After:
    pod.webServer
      ..addRoute(
        appleIDP.revokedNotificationRoute(),
        '/hooks/apple-notification',
      )
      ..addRoute(
        appleIDP.webAuthenticationCallbackRoute(),
        '/auth/callback',
      );
    

@coderabbitai

coderabbitai Bot commented Nov 12, 2025

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@nielsenko
nielsenko force-pushed the apple-revocation branch 2 times, most recently from c72b460 to 7f1850d Compare November 12, 2025 11:36
@nielsenko nielsenko self-assigned this Nov 12, 2025
@nielsenko
nielsenko marked this pull request as ready for review November 12, 2025 14:22
@nielsenko
nielsenko requested a review from SandPod November 12, 2025 14:22
@nielsenko

Copy link
Copy Markdown
Collaborator Author

There are known issues when using on web.

@nielsenko

Copy link
Copy Markdown
Collaborator Author

Rebased on main

@SandPod SandPod left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@nielsenko
nielsenko merged commit 233e245 into serverpod:main Nov 12, 2025
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 12, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Complete new authentication system implementation and cleanup Create Apple authentication module

2 participants