Push Server: Architecture
The Push Server runs as one Spring Boot process that contains the HTTP APIs, the RabbitMQ publisher and consumers, the FCM and APNs adapters, the JDBC repositories and the scheduled maintenance jobs. All replicas share one SQL database, one RabbitMQ broker, one Redis replay store and the same persistent server keys.
Components at a glance
Section titled “Components at a glance”| Component | Role |
|---|---|
| Backend caller | Customer backend that sends messages, reads state and verifies device tokens through the Messaging API |
| Device app | Registers the device, retrieves and decrypts messages, reports state and sends callbacks through the Mobile API |
| Push Server | Validates, persists, encrypts and delivers messages; forwards callbacks |
| SQL database | Devices, messages, recipients, outbox, fallbacks, diagnostics and reporting data |
| RabbitMQ | Asynchronous delivery commands and delayed retries |
| Redis | Replay protection for device request signatures (outside development) |
| FCM / APNs | Push providers that wake the device or display public notifications |
| Callback target | Customer backend endpoint that receives verified device answers |
The server listens on three connectors:
| Port (default) | Purpose |
|---|---|
8080 |
Public APIs (/push/api/v2, /push/.well-known/jwks.json) and API documentation |
8090 |
Admin connector: monthly usage reports (/push/api/v1) and the operator dashboard (/push/ui/dashboard) |
8181 |
Actuator management endpoints (health, info, Prometheus) |
Modules
Section titled “Modules”| Module | Responsibility |
|---|---|
m8ty-server |
Boot entry point, bean wiring, security configuration, attestation verifiers, Liquibase, optional audit publishing |
m8ty-push-tenant-config |
Strict binding and startup validation of the tenant map and loading of credential files |
m8ty-push-domain-models |
Domain values, delivery states and transitions, encrypted configuration helper |
m8ty-push-dto |
Application and processing DTOs |
m8ty-push-domain-validation |
Request validation, lifetime limits, sender rules, callback URL policy |
m8ty-push-domain-services |
Retry and state policies, provider selection, sender configuration, active-device accounting |
m8ty-push-application-api |
Internal use-case interfaces (not an HTTP API) |
m8ty-push-application |
Registration, token issuance, message submission and retrieval, device directory, reports |
m8ty-push-repository-interfaces |
Persistence ports |
m8ty-push-repository |
JDBC implementations |
m8ty-push-security-interfaces |
Contracts for keys, replay protection and attestation |
m8ty-push-crypto |
JOSE transport, JWK thumbprints, PKCE and digests, HTTP message signature validation |
m8ty-push-rest-api |
Messaging, mobile and public-key controllers, callback proxy, signature and tenant filters |
m8ty-push-adm-rest-api |
Admin reporting controller and admin-port filter |
m8ty-push-rapidocs |
RapiDoc pages and OpenAPI document selection per connector |
m8ty-push-message-publisher |
Queue topology, publishing and delayed redelivery |
m8ty-push-message-consumer |
Listeners, per-recipient encryption, provider delivery, state updates |
m8ty-push-provider-interfaces |
Provider adapter contract, adapter selection, per-tenant token cache |
m8ty-push-provider-http |
Shared HTTP/2 transport for provider calls with DNS/IP validation |
m8ty-push-fcm-adapter |
FCM delivery through the Firebase Admin SDK with per-customer/app credentials |
m8ty-push-apns-adapter |
Direct APNs requests with per-customer/app JWT signing and caching |
m8ty-push-housekeeping |
Scheduled, bounded deletion jobs |
m8ty-push-reporting-web |
Optional operator dashboard (Thymeleaf) and customer reporting endpoints |
m8ty-logging |
Logging annotations for method and duration logging |
m8ty-push-rest-client-dart |
OpenAPI-generated Dart (Dio) client packages |
Application services depend only on repository ports; the server module composes JDBC repositories, queue publishing and application implementations. HTTP controllers use the application interfaces.
Tenants and tenant configuration
Section titled “Tenants and tenant configuration”A tenant represents one customer. Each customer owns one or more independent apps, each with an Android and/or iOS variant. Configuration lives in one external YAML file that is imported at startup (SPRING_CONFIG_IMPORT=file:/.../tenants.yaml) under m8ty.push.tenants:
| Level | Settings |
|---|---|
Customer (m8ty.push.tenants.<tenantId>) |
enabled, JWT trust (jwt), request limits and quotas (limits), optional apns-send-via-fcm default |
App (...apps.<appId>) |
enabled, native identities (application), fcm, apns, Play Integrity credentials (attestation), senders, callbacks (credentials, OAuth realms, allowed networks), optional apns-send-via-fcm |
Key rules:
- Nothing is inherited between customers or between sibling apps: identities, provider and attestation credentials, sender policies, callback credentials and OAuth realms are resolved for the exact customer/app.
- Every tenant API call carries the app in the
appIdquery parameter. It may be omitted only when the customer has exactly one app. - Disabling a customer or app blocks registration, device and backend API access, background delivery, fallbacks and callbacks. Devices and messages are not deleted.
- The configuration is a startup snapshot: changes require a rollout of every replica.
- Startup validation rejects incomplete enabled apps (missing provider or attestation credentials), duplicate native identities and Firebase projects or APNs keys reused across customers.
- Single-app installations keep the app ID
default.
Server-wide settings such as database, broker, Redis, ports, provider URLs and timeouts, attestation enforcement, housekeeping and reporting are environment variables, not part of the tenant map. See Deployment and Operations.
Persistence
Section titled “Persistence”The server uses JDBC repositories over a SQL database. Liquibase owns the schema.
| Database | Status |
|---|---|
| PostgreSQL | Production; optional row-level security (RLS) |
| Oracle 19c | Production with RLS disabled (Oracle VPD is not implemented) |
| H2, MariaDB | Development and compatibility only |
Important tables:
| Table | Purpose |
|---|---|
device, device_notification_token, device_verifier_proof |
Device identity, public key, status, preferences, one push token per device, registration proofs |
registration_data |
Registration nonces with PKCE challenge and expiry |
device_opaque_token |
Hashed one-time device authentication tokens |
push_message, processed_request |
Message metadata, lifetime, aggregate state, callback destination; deduplication by correlation ID |
push_outbox |
Transactional outbox for broker publication |
message_recipient |
Per-device state, provider claim, encrypted payload, localized text snapshot |
notification_fallback |
Durable public fallback jobs for private notifications |
device_access_log, active_device_log |
Access events and monthly active-device accounting |
Production uses separate database logins with least privilege: a runtime login for request processing, a maintenance login for global jobs (outbox leases, fallback claims, housekeeping), a read-only reporting login restricted to metadata columns, and a migration login used only by the dedicated --migrate-database command. Normal production startup never runs Liquibase.
Queues
Section titled “Queues”Message submission does not wait for provider delivery. The publisher and consumer modules use RabbitMQ:
| Element | Details |
|---|---|
| Exchange | Durable direct exchange m8ty.nhub-push.v1.dx |
INSTANT messages |
Queue m8ty.nhub-push.api.v1.commands.instant-messages (queue TTL 120 s) |
ALERT messages |
Queue m8ty.nhub-push.api.v1.commands.standard-messages (queue TTL 900 s) |
| Dead letters | ...standard-messages.dlqueue (4 hours) |
| Delayed retries | m8ty.nhub-push-delay.v1.wait.5m (5 minutes) |
| Unroutable messages | m8ty.no-routes.dlqueue |
- Publisher: submission stores the message, the deduplication record and an outbox command in one transaction. An outbox dispatcher publishes the command with publisher confirms and deletes the outbox row afterwards. Publication is scheduled fairly across customers.
- Consumer: listeners prepare recipients and call the providers in bounded turns of at most ten devices; remaining work continues through the outbox. Acknowledgement is manual. Failures are republished to the five-minute delay queue while the retry limit (3 for
INSTANT, 5 forALERT) and the message lifetime allow it; otherwise remaining recipients are marked failed. - Queues are quorum queues with capacity limits (default 10,000 ready commands and 64 MiB per queue) and
reject-publishoverflow behavior.
Provider adapters
Section titled “Provider adapters”| Adapter | Used for | Authentication |
|---|---|---|
FCM (m8ty-push-fcm-adapter) |
Android; iOS when routed through FCM | Firebase Admin SDK with the app’s original Google service-account JSON |
APNs (m8ty-push-apns-adapter) |
iOS direct delivery | APNs provider JWTs signed with the app’s .p8 key; tokens cached per customer/app |
HTTP transport (m8ty-push-provider-http) |
Shared HTTP/2 client for provider calls | Validates DNS answers at connection time, blocks private and metadata addresses, no redirects or transport retries |
Provider selection uses the device OS, its stored token and the effective apns-send-via-fcm setting (app override, then customer override, then the global default true). Each device stores exactly one push token. FCM messages restrict delivery to the configured Android package and Apple bundle ID of the exact app. Outside development, provider origins are restricted to the official FCM and APNs HTTPS hosts.
A provider 2xx response means SENT (accepted by the provider), not that the device received or displayed the notification. Uncertain outcomes (for example a timeout after transmission) keep the recipient claim and are not resent automatically.
Encryption and private notifications
Section titled “Encryption and private notifications”- The server has a persistent EC P-256 key pair (PKCS#12 keystore) and publishes its public keys at
/push/.well-known/jwks.json. - During registration, the device sends its public key encrypted to the server key (ECDH-ES+A256KW / A256GCM) inside a device-signed JWT.
- For each recipient, private content is signed by the server (ES256 JWT) and encrypted to the device key as compact JWE (ECDH-ES+A256KW for EC keys, RSA-OAEP for RSA keys, A256GCM content encryption).
- With a
privateNotification, the provider receives only a silent push containing thepushId. The app fetches the ciphertext over HTTPS, decrypts it and displays the notification locally. - A durable fallback job sends the neutral
publicNotificationif the device has not retrieved the message within a server-controlled timeout (default 15 seconds).
This is delivery encryption between server and device. The sender API, broker, outbox and database are trusted server-side components.
Housekeeping
Section titled “Housekeeping”Scheduled jobs delete data in bounded batches (default 999 rows, at most 1000 batches per run):
| Job | Default schedule |
|---|---|
| Expired messages (with recipients and outbox children) older than the retention (default 3 days) | 0 0 1 * * * |
| Deduplication records | 0 30 0 * * * |
| Expired or used opaque device tokens | 0 0 2 * * * |
| Expired or used registration nonces | 0 30 2 * * * |
A message is only deleted when both its expiry and any callback expiry are older than the retention cutoff.
Reporting web
Section titled “Reporting web”The optional m8ty-push-reporting-web module provides:
- Operator dashboard at
/push/ui/dashboardon the admin connector: registrations, de-registrations, message traffic, active versus total devices, platform, version and language distributions, and a current device inventory across all tenants. Authentication is either an OIDC access proxy forwarding short-lived operator tokens or explicitly configured HTTP Basic. - Customer reporting endpoints on the public connector (
/push/api/v2/{tenantId}/reporting/...), restricted to the customer’s own apps.
Reporting reads through its own read-only database login.
Security model
Section titled “Security model”| Caller | Mechanism |
|---|---|
| Backend | OAuth 2.0 bearer JWT (RS256) verified against the customer’s own trust (issuer discovery, JWKS or static key); requires audience push, endpoint scopes and roles, the path tenant in tenant_id, an exact app grant in app_access, and a lifetime of at most 15 minutes by default |
| Device (registration) | PKCE nonce, JOSE key proof and platform attestation (Play Integrity or Apple App Attest); no bearer token |
| Device (all other calls) | RFC 9421 HTTP message signature with the registered device key, body digest and replay nonce stored in Redis |
| Operator | Dashboard on the admin connector only, with OIDC proxy tokens (dedicated issuer and audience) or Basic credentials |
Additional controls: per-customer and per-IP request limits, monthly and pending-work quotas, a request body limit, guarded outbound connections for callbacks, OAuth and providers, and logs that never contain tokens, credentials or notification content. The dev profile disables bearer authorization and must never be used in production; production startup rejects disabled attestation.
Core flows
Section titled “Core flows”Device registration
Section titled “Device registration”- The app fetches the server public keys from
GET /push/.well-known/jwks.json. - It generates a device key pair and a PKCE verifier, and calls
GET /push/api/v2/{tenantId}/devices/registrationwith the S256code_challenge. The server stores a nonce valid for five minutes. - The app builds
registrationData(nonce, encrypted device key material, device info with language and OS, push token) and obtains platform attestation bound to the exact bytes ofregistrationData. - It posts the raw JSON with
registrationDataandattestationDatatoPOST /push/api/v2/{tenantId}/devices/registration?code_verifier=.... - The server consumes the nonce, checks PKCE, tenant and app, decrypts and verifies the device key, and validates properties and the push token.
- It verifies Play Integrity (through Google) or Apple App Attest (locally against the configured trust store) against the app’s configured identity.
- On success it atomically stores an
AUTHORIZEDdevice and returns 201. A failed attestation creates no device; the nonce stays consumed.
Device authentication
Section titled “Device authentication”- Every device request (token issuance, message retrieval, state update, callback, token and preference updates) carries
Signature-Input,SignatureandContent-Digestheaders. - The signature filter resolves the key of the
AUTHORIZED,ACTIVEdevice for the path tenant and app, matches the key ID to its JWK thumbprint, and checks algorithm, age and body digest. - It claims the nonce in the replay store and verifies the signature; failures return 401.
- For login flows, the device calls
GET .../devices/{deviceId}/tokenand receives a one-time opaque token valid for five minutes. - The device hands the token to the customer backend, which calls
POST .../devices/{deviceId}/token/verifywith its bearer JWT. The server consumes the token once and confirms the device (202), or returns 409.
Message delivery
Section titled “Message delivery”- The backend posts a message with a bearer JWT and an
X-Correlation-Id. - The server validates the request and deduplicates by customer, app and correlation ID; a duplicate returns the original
pushId. - It stores metadata, the deduplication record and an outbox command in one transaction and returns 202 with the
pushId. - The outbox dispatcher publishes the command to the
INSTANTor standard queue and waits for broker confirmation. - The consumer resolves eligible devices, selects the provider, freezes the localized text per recipient and stores the encrypted payload per device.
- It claims each recipient, sends the provider request (silent
pushId-only push for private notifications, public alert otherwise) and recordsSENT,EXPIREDorERROR. - Retryable failures go to the delay queue; for private notifications a fallback job sends the public notification if the device has not retrieved the message in time.
Message retrieval and state
Section titled “Message retrieval and state”- The woken app lists messages (
GET .../devices/{deviceId}/messages, cursor-based) or fetches one message bypushId, signed with its device key. - The server returns the public notification and the per-device
encryptedNotificationand records the retrieval, which cancels a pending fallback. INSTANTmessages are markedDELIVEREDand archived on first read;ALERTmessages can be read repeatedly.- The app decrypts the JWE, verifies the nested server signature and displays the notification.
- The app reports
delivered,readordeletedwith a signedPUTon the message; the aggregate message state is recomputed asynchronously.
Callbacks
Section titled “Callbacks”- The backend includes a
callback(URL and auth type) in the message; the URL must be permitted by the sender’s policy in the tenant configuration. - The app signs the answer with its device key, encrypts it to the server key and posts it to
.../messages/{pushId}/callback. - The server checks that the recipient is
DELIVEREDorREADand the callback has not expired, decrypts the JWE and verifies the device signature. - It resolves the configured outbound credentials (or obtains an OAuth token for SERVICE_TOKEN) and durably claims the recipient.
- It posts the decrypted JSON to the backend with an
Idempotency-Keyheader. On a 2xx response the recipient becomesANSWEREDand the device receives 200; a non-2xx response returns 502.
See Also
Section titled “See Also”- Push Server — overview and capabilities
- Push Server: Integration and API — endpoints, headers and examples
- Push Server: Deployment and Operations — configuration and operations
© m8ty GmbH 2023 · m8ty.eu
