Keep access tokens and raw PII out of the Messenger transport - #49
Open
loevgaard wants to merge 1 commit into
Open
Keep access tokens and raw PII out of the Messenger transport#49loevgaard wants to merge 1 commit into
loevgaard wants to merge 1 commit into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #49 +/- ##
============================================
+ Coverage 77.35% 77.61% +0.26%
- Complexity 140 148 +8
============================================
Files 30 32 +2
Lines 468 487 +19
============================================
+ Hits 362 378 +16
- Misses 106 109 +3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
loevgaard
force-pushed
the
fix/16-sync-failures
branch
from
September 7, 2026 12:03
7107a61 to
b06fbd4
Compare
loevgaard
force-pushed
the
fix/17-pii-in-transport
branch
from
September 7, 2026 12:03
9a99ee8 to
dcbe1cb
Compare
loevgaard
force-pushed
the
fix/16-sync-failures
branch
from
September 7, 2026 12:18
b06fbd4 to
db88227
Compare
loevgaard
force-pushed
the
fix/17-pii-in-transport
branch
from
September 7, 2026 12:18
dcbe1cb to
af21153
Compare
loevgaard
force-pushed
the
fix/16-sync-failures
branch
from
September 7, 2026 12:46
db88227 to
bb2ba25
Compare
loevgaard
force-pushed
the
fix/17-pii-in-transport
branch
from
September 7, 2026 12:46
af21153 to
bac5d1e
Compare
loevgaard
force-pushed
the
fix/16-sync-failures
branch
from
September 7, 2026 12:51
bb2ba25 to
865684c
Compare
loevgaard
force-pushed
the
fix/17-pii-in-transport
branch
from
September 7, 2026 12:51
bac5d1e to
c9f1d9d
Compare
SendEvent carried the Event object, so routing it to a transport wrote the access token and every raw email, phone number and name into that transport's storage, and into the failure transport on failure. Hashing only happened later, inside Client::sendEvent(). The command now carries the finished payload and pixel ids only. Access tokens are resolved at send time through AccessTokenResolverInterface. Fixes #17
loevgaard
force-pushed
the
fix/17-pii-in-transport
branch
from
September 7, 2026 12:57
c9f1d9d to
5c3470c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #17
Problem
SendEventcarried the wholeEventobject. At dispatch time that object holds the pixels including their access tokens, and the raw email addresses, phone numbers, names and dates of birth the application attached, because normalisation and hashing only happen insideParameters::getPayload(), which the SDK calls later in the handler.Routing the command to a transport, which is the recommended setup, therefore wrote all of that into the transport's storage, into the failure transport when it failed, and into anything that dumps messages such as
messenger:failed:show. Failure transports are often kept indefinitely, so it was a retention problem as well as a secrets problem.Change
SendEventnow carries the finished payload:built with
SendEvent::fromEvent($event). The payload is produced by the SDK at dispatch time, so it is already normalised and hashed, and only pixel ids travel.Access tokens are resolved when the event is sent, through a new
AccessTokenResolverInterface.ConfigurationBasedAccessTokenResolverreads them from thepixelsconfiguration, which is request independent and therefore safe to run in a worker. Applications with their ownPixelProviderInterfacealias the resolver too, as documented inREADME.mdandUPGRADE.md.PreparedEvent(internal) hands the precomputed payload back toClientInterface::sendEvent(), which takes anEvent. It extends the SDK'sEvent, which is explicitly documented as non-final for this kind of extension, and overridesgetPayload().A welcome side effect: everything in the message is now a scalar or an array, so it also survives the Symfony serializer rather than requiring the PHP one.
Tests
The important one serialises a message built from an event carrying an access token, an email address, a phone number and a first name, then asserts none of those four strings appear in the serialised output, while the payload holds the SHA-256 of the email. Plus three tests for the resolver, including the fact that numeric pixel ids become integer array keys in PHP, and three for the rewritten handler.