Skip to content

PAR-772: StoreIntegration Signature Redesign#54

Merged
mescalantea merged 15 commits intomasterfrom
refactor/PAR-772-StoreIntegration-Signature-Redesign
Apr 28, 2026
Merged

PAR-772: StoreIntegration Signature Redesign#54
mescalantea merged 15 commits intomasterfrom
refactor/PAR-772-StoreIntegration-Signature-Redesign

Conversation

@mescalantea
Copy link
Copy Markdown
Contributor

@mescalantea mescalantea commented Apr 27, 2026

What is the goal?

Replace the random webhook signature with a deterministic HMAC-SHA256 derived from the ApiAccount password and store ID. Switch store integration deletion to identify by webhook URL instead of integrationId. This eliminates the need for the `StoreIntegration` database record, repository, and entity entirely — preventing duplicate API entries on disconnect/reconnect cycles.

References

  • Issue: PAR-772
  • Related pull-requests: N/A
  • Sentry errors: N/A
  • Any other references (AppSignal, Prometheus, ...): N/A

How is it being implemented?

  • `StoreIntegrationService` constructor swaps `StoreIntegrationRepositoryInterface` for `ConnectionDataRepositoryInterface`. Signature is now computed via `HMAC::generateHMAC([$storeId], $password)` instead of random bytes stored in DB.
  • `deleteStoreIntegration` accepts `ConnectionData` directly and computes the webhook URL internally — no longer requires a `StoreIntegration` model.
  • `DeleteStoreIntegrationRequest` / `DeleteStoreIntegrationHttpRequest` updated to carry a webhook URL string instead of a `StoreIntegration` object.
  • `DisconnectService` simplified: no more `StoreIntegrationRepositoryInterface` dependency.
  • `ConnectionService`: `skipIfExists` parameter removed — deterministic signature makes calls idempotent.
  • `BootstrapComponent` rewired accordingly; `StoreIntegrationRepositoryInterface` registration removed.
  • Domain model, repository interface, DataAccess repository, and ORM entity for `StoreIntegration` deleted.

Opportunistic refactorings

Removed the `StoreIntegration` DB layer entirely (model, repository interface, DataAccess implementation, ORM entity, mock, and tests) since it is no longer needed.

Caveats

  • Breaking change (major version bump required): removed `StoreIntegrationRepositoryInterface`, changed `StoreIntegrationService` constructor, changed `deleteStoreIntegration` signature, removed `skipIfExists`.
  • Password change regenerates the signature, creating a new API entry — acceptable since this is far less frequent than disconnect/reconnect cycles.
  • SeQura API must support deletion by webhook URL before this library version ships.

Does it affect (changes or update) any sensitive data?

No sensitive data affected. API passwords are only used transiently to compute the HMAC and are never stored by this code.

How is it tested?

`StoreIntegrationServiceTest` rewritten with HMAC assertions and no DB interactions. All 754 PHPUnit tests pass. `phpstan` (level 6) and `phpcs` clean.

How is it going to be deployed?

Requires a major version bump. Plugin maintainers must:

  • Remove any usage of `StoreIntegrationRepositoryInterface`
  • Update `StoreIntegrationService` constructor injection (swap repo for `ConnectionDataRepositoryInterface`)
  • Drop the `StoreIntegration` DB table migration in their plugin

mescalantea and others added 6 commits April 27, 2026 12:47
…ationRequest, DeleteStoreIntegrationHttpRequest

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…erface

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ete repository tests

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
mescalantea and others added 9 commits April 27, 2026 15:48
…gnature payload to include storeUrl

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…nService factory and BaseTestCase

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…C payload and rename test

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…n three test files)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…tionData entries

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…issing validateWebhookSignature override)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…st payload, defensive URL clone)

Use HMAC::validateHMAC in validateWebhookSignature and hoist the
storeId+storeUrl payload out of the per-connection loop so multi-
deployment webhook validation does one store-info lookup, not N.
buildWebhookUrl now returns a fresh URL so callers cannot accumulate
storeId/signature queries on a cached integration URL instance.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@mescalantea mescalantea merged commit d173aa2 into master Apr 28, 2026
5 checks passed
@mescalantea mescalantea deleted the refactor/PAR-772-StoreIntegration-Signature-Redesign branch April 28, 2026 09:33
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