Repository navigation
feat(auth2): Add Relic handler for Apple server to server notifications webhook - #3855
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the 📝 WalkthroughWalkthroughA new static method, Changes
Sequence Diagram(s)sequenceDiagram
participant AppleServer as Apple Server
participant Server as Server (Handler)
participant Callback as User Callback
AppleServer->>Server: POST /notification (with JSON body)
Server->>Server: Read raw body as UTF-8 string
Server->>Server: Parse JSON and extract payload
Server->>Server: Decode payload into AppleServerNotification
Server->>Callback: Invoke handler(notification)
Callback-->>Server: Handler completes (void or Future<void>)
Server->>AppleServer: Respond HTTP 200 OK
Estimated code review effort🎯 2 (Simple) | ⏱️ ~7 minutes Possibly related PRs
✨ Finishing Touches🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
modules/new_serverpod_auth/serverpod_auth_apple_account/serverpod_auth_apple_account_server/lib/src/business/apple_accounts.dart(2 hunks)
🧰 Additional context used
🧠 Learnings (12)
📓 Common learnings
Learnt from: tp
PR: serverpod/serverpod#3787
File: modules/new_serverpod_auth/serverpod_auth_apple_account/serverpod_auth_apple_account_server/lib/src/business/apple_accounts.dart:65-67
Timestamp: 2025-07-15T13:10:16.490Z
Learning: In Serverpod Apple authentication, tp prefers adding a `lastRefreshed` field to the database model to track when refresh tokens were last validated, enabling periodic refresh token validation strategy for Apple Sign-In accounts.
Learnt from: tp
PR: serverpod/serverpod#3787
File: modules/new_serverpod_auth/serverpod_auth_apple_account/serverpod_auth_apple_account_server/pubspec.yaml:18-18
Timestamp: 2025-07-15T13:38:58.183Z
Learning: For Sign in with Apple authentication, there are two distinct packages: `sign_in_with_apple` is the client-side package for mobile apps, while `sign_in_with_apple_server` is a server-side utility package for handling Sign in with Apple tokens and validation on Dart servers.
Learnt from: tp
PR: serverpod/serverpod#3788
File: modules/new_serverpod_auth/serverpod_auth_apple/serverpod_auth_apple_server/lib/src/endpoints/apple_account_base_endpoint.dart:32-40
Timestamp: 2025-07-16T07:33:13.578Z
Learning: In Serverpod Apple authentication, the `lastRefreshed` field should only be updated in the `checkAccountStatus` method when the refresh token is actually used and validated, not during sign-in. During sign-in, the system uses the Apple identity token to find users by their Apple-provided user identifier, without checking or validating the refresh token.
📚 Learning: for sign in with apple authentication, there are two distinct packages: `sign_in_with_apple` is the ...
Learnt from: tp
PR: serverpod/serverpod#3787
File: modules/new_serverpod_auth/serverpod_auth_apple_account/serverpod_auth_apple_account_server/pubspec.yaml:18-18
Timestamp: 2025-07-15T13:38:58.183Z
Learning: For Sign in with Apple authentication, there are two distinct packages: `sign_in_with_apple` is the client-side package for mobile apps, while `sign_in_with_apple_server` is a server-side utility package for handling Sign in with Apple tokens and validation on Dart servers.
Applied to files:
modules/new_serverpod_auth/serverpod_auth_apple_account/serverpod_auth_apple_account_server/lib/src/business/apple_accounts.dart
📚 Learning: in serverpod apple authentication, tp prefers adding a `lastrefreshed` field to the database model t...
Learnt from: tp
PR: serverpod/serverpod#3787
File: modules/new_serverpod_auth/serverpod_auth_apple_account/serverpod_auth_apple_account_server/lib/src/business/apple_accounts.dart:65-67
Timestamp: 2025-07-15T13:10:16.490Z
Learning: In Serverpod Apple authentication, tp prefers adding a `lastRefreshed` field to the database model to track when refresh tokens were last validated, enabling periodic refresh token validation strategy for Apple Sign-In accounts.
Applied to files:
modules/new_serverpod_auth/serverpod_auth_apple_account/serverpod_auth_apple_account_server/lib/src/business/apple_accounts.dart
📚 Learning: in serverpod apple authentication, the `lastrefreshed` field should only be updated in the `checkacc...
Learnt from: tp
PR: serverpod/serverpod#3788
File: modules/new_serverpod_auth/serverpod_auth_apple/serverpod_auth_apple_server/lib/src/endpoints/apple_account_base_endpoint.dart:32-40
Timestamp: 2025-07-16T07:33:13.578Z
Learning: In Serverpod Apple authentication, the `lastRefreshed` field should only be updated in the `checkAccountStatus` method when the refresh token is actually used and validated, not during sign-in. During sign-in, the system uses the Apple identity token to find users by their Apple-provided user identifier, without checking or validating the refresh token.
Applied to files:
modules/new_serverpod_auth/serverpod_auth_apple_account/serverpod_auth_apple_account_server/lib/src/business/apple_accounts.dart
📚 Learning: high-level serverpod_auth_* packages (like serverpod_auth_apple_client) should re-export their serve...
Learnt from: tp
PR: serverpod/serverpod#3826
File: modules/new_serverpod_auth/serverpod_auth_apple/serverpod_auth_apple_client/lib/serverpod_auth_apple_client.dart:1-1
Timestamp: 2025-07-24T13:01:52.743Z
Learning: High-level serverpod_auth_* packages (like serverpod_auth_apple_client) should re-export their serverpod_auth_* dependencies so that consumers only need to import the high-level package and don't get warnings about importing from non-dependency packages. The re-exports should hide conflicting elements like 'Caller' and 'Protocol' to avoid naming conflicts. This pattern prevents users from needing to directly depend on multiple internal implementation packages.
Applied to files:
modules/new_serverpod_auth/serverpod_auth_apple_account/serverpod_auth_apple_account_server/lib/src/business/apple_accounts.dart
📚 Learning: in serverpod, tp prefers importing the full package (e.g., 'package:serverpod_auth_migration_server/...
Learnt from: tp
PR: serverpod/serverpod#3747
File: modules/new_serverpod_auth/serverpod_auth_migration/serverpod_auth_migration_server/lib/src/business/migrating_email_endpoint_base.dart:4-4
Timestamp: 2025-07-02T16:07:50.947Z
Learning: In Serverpod, tp prefers importing the full package (e.g., 'package:serverpod_auth_migration_server/serverpod_auth_migration_server.dart') as a baseline rather than using smaller local imports, even within the same package where it might be considered a "self-import".
Applied to files:
modules/new_serverpod_auth/serverpod_auth_apple_account/serverpod_auth_apple_account_server/lib/src/business/apple_accounts.dart
📚 Learning: in the serverpod project, `dart pub get` commands work fine on flutter packages both locally and in ...
Learnt from: tp
PR: serverpod/serverpod#3721
File: util/pub_get_all:0-0
Timestamp: 2025-06-27T08:39:36.440Z
Learning: In the Serverpod project, `dart pub get` commands work fine on Flutter packages both locally and in CI environments, even when the package has `flutter: sdk: flutter` dependencies in pubspec.yaml. The technical constraint of Flutter SDK dependencies causing `dart pub` failures may not apply in all environments or recent Dart versions.
Applied to files:
modules/new_serverpod_auth/serverpod_auth_apple_account/serverpod_auth_apple_account_server/lib/src/business/apple_accounts.dart
📚 Learning: in serverpod authentication modules, docker compose files for different auth modules (like serverpod...
Learnt from: tp
PR: serverpod/serverpod#3783
File: modules/new_serverpod_auth/serverpod_auth_apple/serverpod_auth_apple_server/docker-compose.yaml:4-7
Timestamp: 2025-07-14T07:47:16.177Z
Learning: In Serverpod authentication modules, Docker compose files for different auth modules (like serverpod_auth_apple_server and serverpod_auth_apple_account_server) use the same ports (9090 for Postgres, 9091 for Redis) by design, since only one container/Docker compose setup is intended to run at a time.
Applied to files:
modules/new_serverpod_auth/serverpod_auth_apple_account/serverpod_auth_apple_account_server/lib/src/business/apple_accounts.dart
📚 Learning: in serverpod migration testing, it's appropriate for test servers like serverpod_new_auth_test_serve...
Learnt from: tp
PR: serverpod/serverpod#3747
File: tests/serverpod_new_auth_test/serverpod_new_auth_test_server/pubspec.yaml:37-38
Timestamp: 2025-07-02T16:09:27.702Z
Learning: In Serverpod migration testing, it's appropriate for test servers like serverpod_new_auth_test_server to include dependencies on both legacy packages (e.g., serverpod_auth_server) and new modular packages to enable comprehensive testing of migration paths from old to new authentication systems.
Applied to files:
modules/new_serverpod_auth/serverpod_auth_apple_account/serverpod_auth_apple_account_server/lib/src/business/apple_accounts.dart
📚 Learning: in serverpod, first-party packages like serverpod_auth_server can appropriately use blanket `invalid...
Learnt from: exaby73
PR: serverpod/serverpod#3741
File: modules/serverpod_auth/serverpod_auth_server/analysis_options.yaml:14-16
Timestamp: 2025-07-01T13:01:27.054Z
Learning: In Serverpod, first-party packages like serverpod_auth_server can appropriately use blanket `invalid_use_of_internal_member: ignore` directives in their analysis_options.yaml since they use internal Database methods internally without exposing them in their public APIs to end users.
Applied to files:
modules/new_serverpod_auth/serverpod_auth_apple_account/serverpod_auth_apple_account_server/lib/src/business/apple_accounts.dart
📚 Learning: in serverpod test files, tp prefers using nullable late variables for authenticationinfo in tests (e...
Learnt from: tp
PR: serverpod/serverpod#3672
File: tests/serverpod_test_server/test_integration/test_tools/test_session_builder_test.dart:10-30
Timestamp: 2025-06-18T14:49:11.263Z
Learning: In Serverpod test files, tp prefers using nullable late variables for AuthenticationInfo in tests (e.g., `late AuthenticationInfo? authenticationInfo;`) rather than non-nullable ones to avoid using `!` operators and to get clearer error messages when authentication setup fails. This provides better diagnostics when `session.authenticated` returns null.
Applied to files:
modules/new_serverpod_auth/serverpod_auth_apple_account/serverpod_auth_apple_account_server/lib/src/business/apple_accounts.dart
📚 Learning: in serverpod packages, the `uuid` package is re-exported through a chain: `serverpod_auth_session_cl...
Learnt from: tp
PR: serverpod/serverpod#3721
File: modules/new_serverpod_auth/serverpod_auth_session/serverpod_auth_session_flutter/test/serverpod_auth_session_flutter_test.dart:1-7
Timestamp: 2025-06-27T07:44:09.048Z
Learning: In Serverpod packages, the `uuid` package is re-exported through a chain: `serverpod_auth_session_client` re-exports `serverpod_client`, which re-exports `serverpod_serialization`, which re-exports `uuid`. This means `Uuid` class is available in files that import `serverpod_auth_session_client` without needing a direct `uuid` package import.
Applied to files:
modules/new_serverpod_auth/serverpod_auth_apple_account/serverpod_auth_apple_account_server/lib/src/business/apple_accounts.dart
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (40)
- GitHub Check: CLI e2e tests (3.24.0, ubuntu-latest, tests/serverpod_cli_e2e_test)
- GitHub Check: CLI e2e tests (3.32.1, ubuntu-latest, tests/serverpod_cli_e2e_test)
- GitHub Check: Migration e2e tests (3.24.0)
- GitHub Check: Serverpod integration tests (flutter)
- GitHub Check: Bootstrap tests (3.32.1, windows-latest, tests/bootstrap_project)
- GitHub Check: Migration e2e tests (3.32.1)
- GitHub Check: Bootstrap tests (3.24.0, ubuntu-latest, tests/bootstrap_project)
- GitHub Check: Bootstrap tests (3.24.0, windows-latest, tests/bootstrap_project)
- GitHub Check: Bootstrap tests (3.32.1, ubuntu-latest, tests/bootstrap_project)
- GitHub Check: Module integration tests in modules/new_serverpod_auth/serverpod_auth_jwt/serverpod_auth_jwt_server with Flutter 3.32.1
- GitHub Check: Module integration tests in tests/serverpod_test_nonvector/serverpod_test_nonvector_server with Flutter 3.32.1
- GitHub Check: Module integration tests in modules/new_serverpod_auth/serverpod_auth_jwt/serverpod_auth_jwt_server with Flutter 3.24.0
- GitHub Check: Serverpod concurrent integration tests (server) (3.24.0)
- GitHub Check: Version change test
- GitHub Check: Module integration tests in tests/serverpod_test_nonvector/serverpod_test_nonvector_server with Flutter 3.24.0
- GitHub Check: Serverpod concurrent integration tests (server) (3.32.1)
- GitHub Check: dart analyze downgrade (3.32.1, windows-latest)
- GitHub Check: Unit tests Web (3.24.0, windows-latest)
- GitHub Check: serverpod generate (3.32.1)
- GitHub Check: dart analyze downgrade (3.24.0, ubuntu-latest)
- GitHub Check: Unit tests Web (3.32.1, windows-latest)
- GitHub Check: Serverpod E2E web tests (3.32.1)
- GitHub Check: serverpod generate (3.24.0)
- GitHub Check: dart analyze downgrade (3.24.0, windows-latest)
- GitHub Check: dart analyze downgrade (3.32.1, ubuntu-latest)
- GitHub Check: Serverpod E2E web tests (3.24.0)
- GitHub Check: Serverpod E2E IO tests (3.24.0)
- GitHub Check: Serverpod integration tests (server) (3.32.1)
- GitHub Check: Serverpod integration tests (server) (3.24.0)
- GitHub Check: Serverpod E2E IO tests (3.32.1)
- GitHub Check: Flutter unit tests (3.32.1, windows-latest, packages/serverpod_flutter)
- GitHub Check: Flutter unit tests (3.24.0, windows-latest, packages/serverpod_flutter)
- GitHub Check: Unit tests IO (3.32.1, windows-latest)
- GitHub Check: Unit tests IO (3.32.1, ubuntu-latest)
- GitHub Check: Unit tests IO (3.24.0, ubuntu-latest)
- GitHub Check: dart analyze (3.24.0, ubuntu-latest)
- GitHub Check: Unit tests IO (3.24.0, windows-latest)
- GitHub Check: dart analyze latest (3.32.1, windows-latest)
- GitHub Check: dart analyze latest (3.32.1, ubuntu-latest)
- GitHub Check: dart analyze (3.24.0, windows-latest)
🔇 Additional comments (2)
modules/new_serverpod_auth/serverpod_auth_apple_account/serverpod_auth_apple_account_server/lib/src/business/apple_accounts.dart (2)
1-2: LGTM! Necessary imports for the new webhook handler.The
dart:asyncimport is needed forFutureOrin the handler signature, anddart:convertis required for UTF-8 decoding and JSON parsing of the webhook payload.
128-142: Excellent documentation with clear usage example and security guidance.The documentation clearly explains the handler's purpose, provides a practical Router setup example, and importantly highlights the security requirement to remove sessions when receiving consent revocation or account deletion notifications.
|
Thanks for adding this! Hold of with merging this as we have a major refactor of the package structure coming on soon. |
|
I'll update this PR with the new file structure and merge it in. |
Relates to #3453
Just a small follow-up to round out the package.
Summary by CodeRabbit