Repository navigation
fix(messaging): expire push image tokens fifteen days after delivery - #14782
Conversation
The JWT encoder treats its third argument as a lifetime in seconds, but push create and update passed an absolute timestamp, so image tokens carried an expiry decades out. Set the exp claim to the delivery time plus a fifteen-day duration constant, and on update prefer the newly requested schedule.
|
Review complete. 🟡 1 medium 💬 Inline comments (1)
The change replaces the fixed 15-days-from-now image token expiry with a
Reviewed commit: 3ab447a |
🟢 Tier S · Ready to merge
Push image JWTs now use a shared fifteen-day duration and set expiration relative to the message delivery time. Push updates regenerate the image URL token using the effective scheduled time, with E2E assertions covering create, schedule, and reschedule cases.
📂 Walkthrough · 4
Reviewed |
There was a problem hiding this comment.
This PR re-anchors the push-message image-access JWT to the scheduled delivery time (15 days from scheduledAt) and adds e2e coverage for token expiry on rescheduled messages.
Key findings
- 🟡 Rescheduled message keeps stale, expired image JWT — Update.php:310
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
Security rulesNo new WARNING or ERROR findings from security rules. 6 existing findings tracked in
|
A reschedule without a new image kept the token anchored to the old delivery time, so moving delivery more than fifteen days out shipped an expired link.
The findings that requested changes are resolved. See the summary comment for what is still open.
|
@hansi-codes review |
…expiry fix(messaging): expire push image tokens fifteen days after delivery (cherry picked from commit ea7ecdb)
What
Push message create and update sign a JWT for the image URL embedded in the notification. The intent is a token valid until fifteen days after delivery, but the code passed an absolute Unix timestamp as the encoder's
maxAge, whichadhocore/jwttreats as a lifetime in seconds added to the current time. The resultingexpwas decades in the future.Change
APP_PUSH_IMAGE_TOKEN_DURATION(15 days, in seconds).expclaim explicitly to the delivery time (scheduledAt, or now) plus that duration, and pass the duration asmaxAge.scheduledAtover the previously stored one when computing the delivery time.GET /v1/storage/buckets/:bucketId/files/:fileId/push) already validatesexpwith zero leeway, so no change is needed there.Tests
MessagingBase::testCreateDraftPushWithImagenow decodes the JWT payload from the returned image URL and assertsexpis about 15 days after now on create, and about 15 days after the newscheduledAton update (60s tolerance). Both assertions fail on the old code.E2E was not run locally (shared machine); relying on the CI Messaging lane. Pint, PHPStan and Rector pass on the touched files.
Note: tokens issued before this change keep their old expiry; rotating
_APP_OPENSSL_KEY_V1is the only way to invalidate them.Related: appwrite-labs/cloud#6673