Skip to content

Add Vipps MobilePay provider - #2

Merged
canuto merged 1 commit into
mainfrom
feat/vipps-provider
Sep 3, 2026
Merged

Add Vipps MobilePay provider#2
canuto merged 1 commit into
mainfrom
feat/vipps-provider

Conversation

@canuto

@canuto canuto commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Vipps uses the Azure API Management signature scheme, which the generic HMAC handlers cannot express: the signed string is METHOD\nPATH_AND_QUERY\nDATE;HOST;CONTENT_HASH, covering method, path, host and a SHA-256 of the body rather than the body itself.

Two things worth a look in review:

  • Verification is two steps. The signature covers a hash of the body, so checking the signature alone would accept a swapped payload carrying a valid signature. x-ms-content-sha256 is verified against the received bytes first, and there's a test for that swap specifically.
  • Pipe-delimited signature format (<sig>|t=<date>|c=<hash>) instead of the comma-delimited convention the other multi-part providers use, because x-ms-date is RFC1123 and contains its own comma.

Host and path are taken from the required url option rather than the inbound Host header, following square and hubspot.

17 new tests; full suite 111 passing, build clean.

🤖 Generated with Claude Code

https://claude.ai/code/session_01JWFR6tkxmzVJGhNvwQ6rNu

Vipps uses the Azure API Management scheme rather than a plain body HMAC, so
the generic handlers could not express it: the signed string is

  METHOD\nPATH_AND_QUERY\nDATE;HOST;CONTENT_HASH

which covers the method, path, host and a SHA-256 of the body, not the body
itself. The existing {timestamp}/{payload} format has nowhere to put any of
that.

Two details worth calling out:

Verification is two steps. Because the signature covers a *hash* of the body,
checking the signature alone would accept a swapped payload that still carries
a valid signature. x-ms-content-sha256 is checked against the received bytes
first, and there is a test for exactly that swap.

The signature is passed pipe-delimited rather than comma-delimited as the other
multi-part providers do, because x-ms-date is RFC1123 and contains a comma of
its own ("Thu, 30 Mar 2023 08:38:32 GMT").

Host and path come from the required url option rather than the inbound Host
header, following square and hubspot, so a proxy rewriting Host cannot break
verification.

17 tests, covering the tampered-body swap, a mismatched content hash, stale and
unparseable dates, wrong host, wrong path, query strings, custom methods and
secret rotation. Full suite 111 passing, build clean.
@canuto
canuto merged commit f1fc53a into main Sep 3, 2026
1 check passed
@canuto
canuto deleted the feat/vipps-provider branch September 3, 2026 11:54
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.

1 participant