You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 8c6197f
Browse filesBrowse the repository at this point in the historyBrowse files
feat(api): sign HTTP adapter notifications with phone-ID JWT (NdoleStudio#992)
* feat(api): sign HTTP adapter notifications with phone-ID JWT
Sign HTTPS adapter notification requests with a JWT the same way
webhook requests are signed, using the phone ID (a UUID) as the
HMAC secret instead of a per-webhook signing key.
- FCMClient.Send now takes the sending phone's ID so HTTP-transport
clients can generate a bearer token; Firebase/emulator clients
ignore it.
- HTTPNotificationSender signs a JWT (10 min validity, audience is
the endpoint URL with any userinfo stripped) and sends it via the
X-Httpsms-Signature header rather than Authorization, so adapters
can still use HTTP basic auth embedded in the endpoint URL.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* refactor(api): send adapter JWT via Authorization header
Send the phone-signed notification JWT via the standard Authorization
header, matching webhook requests exactly, instead of a dedicated
X-Httpsms-Signature header. Adapter endpoint URLs are no longer
expected to carry HTTP basic auth credentials, since Authorization
is now always used for the bearer JWT; update the corresponding test
to assert basic auth from the URL is ignored.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* test: validate adapter notification JWT auth in emulator
The adapter emulator now requires and validates the phone-ID-signed JWT (Authorization: Bearer) that the API sends with every FCM-compatible notification, mirroring the webhook JWT validation already used in integration tests.
- adapter-emulator: gateway registration now requires phone_id; notification_handler verifies the JWT (HS256, sub==phone_id, iss==api.httpsms.com) before recording/processing, rejecting invalid/missing tokens with 401.
- emulator_test.go: updated existing tests to register phone_id and send valid tokens; added negative tests for missing auth and wrong signing secret.
- helpers_test.go: setupAdapterPhone now upserts the phone before registering the gateway (so phone_id is known), and adds an assertAdapterNotificationJWT helper mirroring assertWebhookJWT.
- adapter_integration_test.go: asserts the JWT on recorded message and heartbeat notifications.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 45ed9de9-a3ad-41cf-ad32-ebec28d9771c
* fix(api): stop embedding phone ID in adapter notification JWT claims
Address PR review: the token used phoneID as both the readable sub claim and the HS256 signing secret, so anyone who saw one token could read the secret and forge further ones. The sub claim is unnecessary since the adapter already knows which phone ID to verify against from its own gateway registration, so it is removed; the phone ID remains the signing secret only.
- http_notification_sender.go: getAuthToken no longer sets Subject.
- adapter-emulator/notification_handler.go: verifyNotificationAuth no longer checks claims.Subject.
- Updated tests in api/pkg/services and tests/ to assert sub is empty instead of equal to the phone ID.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 45ed9de9-a3ad-41cf-ad32-ebec28d9771c
* fix(api): address remaining PR review comments
- fcm_client.go: fix Send doc comment - phoneID identifies the receiving/target phone, not the sending phone.
- adapter-emulator/notification_handler.go: verifyNotificationAuth now requires the HS256 signing method specifically instead of accepting any HMAC variant, matching what the API actually signs with.
- emulator_test.go: added TestNotificationHandlerRejectsNonHS256SigningMethod covering the HS256-only check.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 45ed9de9-a3ad-41cf-ad32-ebec28d9771c
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 45ed9de9-a3ad-41cf-ad32-ebec28d9771c
0 commit comments