No description
  • Go 97.3%
  • Makefile 1.4%
  • Dockerfile 0.9%
  • Go Template 0.4%
Find a file
Zamir Amir 98413eeef1
All checks were successful
CI / test (push) Successful in 16s
CI / specification (push) Successful in 29s
CI / chart-release (push) Successful in 4s
CI / chart (push) Successful in 5s
CI / image (push) Successful in 15s
Release 0.3.0
2026-11-25 16:26:58 +01:00
.forgejo/workflows Scan the rendered chart with KICS on every push and pull request 2026-11-25 10:34:12 +01:00
api Count what the gateway does for the app-uitgever's operator screen 2026-11-25 16:19:57 +01:00
cmd/mailbox-app-push-gateway Count what the gateway does for the app-uitgever's operator screen 2026-11-25 16:19:57 +01:00
helm Release 0.3.0 2026-11-25 16:26:58 +01:00
internal Count what the gateway does for the app-uitgever's operator screen 2026-11-25 16:19:57 +01:00
.dockerignore Wake devices through the app publisher's push gateway 2026-11-23 16:58:01 +01:00
Dockerfile Rename to mailbox-app-push-gateway 2026-11-23 22:46:20 +01:00
go.mod Send seintjes to the mobile app through FCM 2026-11-24 13:07:15 +01:00
go.sum Give the pushgateway a Dutch OpenAPI contract under /push/v1 2026-11-23 22:22:11 +01:00
LICENSE License under EUPL-1.2 2026-11-23 20:10:32 +01:00
Makefile Release the pushgateway with a version, chart and image together 2026-11-24 17:00:31 +01:00
README.md Count what the gateway does for the app-uitgever's operator screen 2026-11-25 16:19:57 +01:00

mailbox-app-push-gateway

Pushgateway: the component of the app publisher that turns a nudge from a hoster into a push through the right push provider. A hoster holds no push credentials, so a self-hosted mailbox can wake the official app too (R5).

Part of the Notificatie voor Burgers walking skeleton. It stores nothing: open WebSockets live in memory, everything else is sealed in the pushtoken. Vocabulary follows the shared glossary.

Providers

Kanaal Provider
web Web Push through the browser's push service, signed with the publisher's VAPID keys. Sent without payload, so the push service of Google, Mozilla or Apple learns nothing; the service worker always shows "Er is post".
websocket A WebSocket to this gateway, kept open by the app while it runs or by the background service mailbox-app-push-agent on every desktop (ADR 0003 in getting-started).
fcm Firebase Cloud Messaging to the mobile app, which reaches Android itself and iOS through APNs. The message only says "Er is post". Signs in with the service account in FCM_SERVICE_ACCOUNT; without it the gateway serves no fcm.

The kanaal is the channel that reaches a device, not its operating system. Only this gateway knows it: every pushtoken seals the kanaal and what reaches the device through it (the WebSocket's connection id, the Web Push subscription, or the Firebase Installation ID) with AES-256-GCM under PUSHTOKEN_KEY, padded to one fixed length. The hoster stores and returns the pushtoken without learning how a device is reached, and the gateway needs no storage. A token it cannot open (forged, altered, or sealed under an earlier key) answers 410.

APNs-direct and WNS get their own provider behind the same interface later.

API

The contract is api/openapi.yaml (OAS 3.1, Dutch, NL API Design Rules). Like in blauwe knop it is committed together with a generated api/openapi.json; CI checks they match, the image carries both in /api/, and every listener serves them. Every response carries API-Version: 1.0.0; errors are application/problem+json.

Public, routed at /push (prefix /push/v1):

  • GET /push/v1/vapid-sleutel → {publiekeSleutel}, for the browser's PushManager.subscribe
  • POST /push/v1/pushtokens {kanaal: "web", webPushAbonnement} or {kanaal: "fcm", fid} → 201 {pushtoken}: exchanges a browser's subscription, or the mobile app's Firebase Installation ID, for a pushtoken; 422 for a kanaal this gateway does not serve here
  • GET /push/v1/verbinding WebSocket: first {"soort":"pushtoken","pushtoken":"…"}, then {"soort":"seintje"} per seintje. The pushtoken is valid only while the connection lives. The gateway pings every connection; after two unanswered pings in a row it closes the connection (1001) and forgets the pushtoken.
  • GET /push/v1/openapi.json and /push/v1/openapi.yaml

Internal, on its own listener (INTERNAL_LISTEN_ADDRESS, default :8081) and Service <release>-internal, never routed, so nobody outside the cluster can make devices buzz:

  • POST /v1/seintjes {pushtoken} → 202 sent, 410 the pushtoken no longer reaches a device (the hoster then forgets it), 502 the push provider refused
  • GET /v1/openapi.json and /v1/openapi.yaml

Management, on its own listener (MANAGEMENT_LISTEN_ADDRESS, default :8082) and Service <release>-management, never routed; only mailbox-app-push-gateway-management-ui reads it:

  • GET /v1/overzicht → per kanaal whether it is served, the devices connected now (websocket), the pushtokens issued and the seintjes sent and failed, the failures per reason, and the latest events (newest first). A pushtoken appears only as its pseudonym, the first 8 hex characters of its SHA-256. The counts live in memory: a restart starts from zero. The gateway does not know which hoster asked for a seintje or who the burger is.
  • GET /v1/openapi.json and /v1/openapi.yaml

Configuration

  • VAPID_PUBLIC_KEY, VAPID_PRIVATE_KEY: from the Secret in vapid.existingSecret
  • VAPID_SUBJECT: contact URL or mailto: that push services require
  • PUSHTOKEN_KEY: base64 of 32 random bytes that seal every pushtoken, from the Secret in pushtokenKey.existingSecret; a new key makes every registered pushtoken gone
  • FCM_SERVICE_ACCOUNT: optional, the JSON of the Firebase service account, from the Secret in fcm.existingSecret; without it the gateway serves no fcm
  • ALLOWED_ORIGINS: comma-separated CORS and WebSocket origins, defaults to *
  • INTERNAL_LISTEN_ADDRESS: listener of the seintjes API, defaults to :8081
  • MANAGEMENT_LISTEN_ADDRESS: listener of the management API, defaults to :8082
  • VERSION: the release shown on the operator screen; the chart sets it to its appVersion
  • RECENT_EVENTS: how many of the latest events the overview keeps, defaults to 100
  • PING_INTERVAL: how often every WebSocket is pinged, defaults to 30s
  • MISSED_PONGS: unanswered pings in a row after which a WebSocket is closed, defaults to 2

Generate a key pair with mailbox-app-push-gateway generate-vapid-keys and a pushtoken key with mailbox-app-push-gateway generate-pushtoken-key (or docker run --rm <image> …).

Development

go test ./...
golangci-lint run ./...
docker build --target production -t code.digitaledienst.overheid.nl/mijn-betaaloverzicht/mailbox-app-push-gateway:0.1.0 .
helm upgrade --install mailbox-app-push-gateway helm

CI

.forgejo/workflows/ci.yml tests and lints every push and pull request. On main it pushes the image code.digitaledienst.overheid.nl/mijn-betaaloverzicht/mailbox-app-push-gateway:<commit>.

Release

make release VERSION=1.2.3   # on an up-to-date main: writes helm/Chart.yaml, commits, tags v1.2.3
git push --follow-tags

The tag pipeline tags the image 1.2.3 and v1.2.3 and publishes the chart at 1.2.3 to the Forgejo Helm registry (see the charts repository). The environments repository pins that version.

License

EUPL-1.2, see LICENSE.