Files
buzz/deploy/charts/buzz-push-gateway/values.yaml
Tom Brow 5268caa866 feat(push-gateway): mint FCM tokens through AWS workload identity federation (#9692)
## Summary

Block's GCP projects forbid service account keys, so the push gateway
can now get its FCM access token by federating its AWS identity (Google
workload identity federation), with no key file.

- `BUZZ_PUSH_FCM_SERVICE_ACCOUNT_PATH` is renamed
`BUZZ_PUSH_FCM_CREDENTIALS_PATH` (no deployment sets it yet). The file
is dispatched on its JSON `type`: `service_account` keeps today's JWT
flow; `external_account` is Google's standard AWS credential
configuration, the file Block's `identity-federation-aws` Terraform
module generates.
- Only the minting step changed. `TokenSource` caching, refresh, backoff
and the Rejected/Unavailable split are as they were.
- A federated mint: AWS credentials (EKS Pod Identity, IRSA or static
env keys; no EC2 metadata), a SigV4-signed STS `GetCallerIdentity`
subject token, Google STS, then `generateAccessToken` for the FCM scope.
One 15 s deadline covers the whole chain.
- Faults: network errors, 5xx and 429 on any hop are Unavailable; other
4xx are Rejected.
- Startup checks the file's shape and the AWS environment but calls
neither AWS nor Google, so an outage can't stop the gateway from serving
iOS. The first mint's result is logged once.
- Helm: `android.fcmServiceAccount` is renamed `android.fcmCredentials`,
mounted as `credentials.json`.

## Validation

- New tests drive `TokenSource` against fake AWS, Google STS and
impersonation servers: the full chain, each hop's failure
classification, a failed refresh keeping a valid cached token, the
overall deadline, and config rejection cases.
- SigV4 known-answer tests use AWS's documented example credentials,
checked against an independent implementation.

Checked live against the dev Firebase project from a local AWS identity:
the federated mint succeeds and FCM accepts the resulting token. Not yet
run from a gateway pod.

---------

Signed-off-by: Tom Brow <tomb@block.xyz>
Co-authored-by: studio <dc2fc481343672df31a689840c09299972e704dac592e0da6f18486646a7ee3e@buzz.block.builderlab.xyz>
2026-11-20 09:10:08 -08:00

143 lines
5.5 KiB
YAML

replicaCount: 2
image:
repository: ghcr.io/block/buzz-push-gateway
# `main` is published by the push-gateway lane on every main push.
tag: main
digest: ""
pullPolicy: IfNotPresent
pullSecrets: []
existingSecret: buzz-push-gateway
# DDL-capable credentials are used only by the pre-install/pre-upgrade migration
# Job. Runtime DATABASE_URL in existingSecret should have DML-only privileges.
migration:
# Applies only to migration Pods, independently of runtime podAnnotations.
podAnnotations: {}
existingSecret: buzz-push-gateway-migrations
databaseUrlKey: DATABASE_URL
# Existing LOGIN role used by runtime DATABASE_URL. Migrations grant it only
# CONNECT plus DML on the six gateway tables in this dedicated database.
runtimeDatabaseRole: buzz_push_gateway_runtime
resources:
requests: {cpu: 50m, memory: 64Mi}
limits: {cpu: 250m, memory: 128Mi}
# Routing origin used only when httpRoute.enabled=true. Not passed to the binary.
gatewayOrigin: ""
maxGrantLifetimeSeconds: 2592000
application:
# Production MUST override this with the exact Apple TEAMID.bundle-id.
appAttestAppId: TEAMID.com.example.buzz
apnsTopic: com.example.buzz
apnsEnvironment: production
apnsCert:
secretName: buzz-push-gateway
secretKey: apns-identity.pem
# Android is off unless enabled. Enabling it needs the package, at least one
# signing certificate digest and the Firebase project and service account.
android:
enabled: false
# Exact application package the attestation must name.
packageName: com.example.buzz
# SHA-256 digests (64 hex characters each) of the app's signing certificates.
signingCertDigests: []
# Verified boot keys (SHA-256 digests, 64 hex characters each) accepted when
# the hardware reports a self-signed boot state. Empty accepts stock Android
# only. Add the published keys of a custom operating system to support it.
bootKeyDigests: []
# Seconds the attestation revocation list may go without a successful refresh
# before Android enrollment fails closed.
revocationGraceSeconds: 604800
fcmProjectId: example-project
# Secret holding Google's credential JSON: a service account key, or an AWS
# workload identity federation config (type external_account) for keyless
# access. Federation also needs AWS_REGION and AWS credentials in the pod.
# As shipped, the chart supports IRSA, whose webhook injects both. EKS Pod
# Identity also needs a region and a NetworkPolicy egress rule to the agent
# (169.254.170.23/32, TCP 80), which this chart does not add.
fcmCredentials:
secretName: buzz-push-gateway
secretKey: fcm-credentials.json
# Optional PEM bundle replacing the built-in Google attestation roots, for a
# reviewed root rollout. Empty secretName keeps the built-in roots.
attestationRoots:
secretName: ""
secretKey: android-attestation-roots.pem
# Rate limit on signed installation calls, per attested key and replica.
signedCallRateLimit:
windowSeconds: 60
maxCalls: 30
appAttestRoot:
secretName: buzz-push-gateway
secretKey: app-attest-root.pem
service:
port: 8080
# Optional Deployment metadata, independent of runtime and migration Pods.
# The chart owns buzz.block.xyz/release-namespace and external-network-policy.
deploymentAnnotations: {}
podAnnotations: {}
httpRoute:
# Disabled by default so a generic install cannot claim an unattached route.
# Enable only when this chart owns a Gateway API route. Environments with an
# existing ingress or service mesh route should keep this disabled.
enabled: false
parentRefs: []
resources:
requests: {cpu: 100m, memory: 128Mi}
limits: {cpu: "1", memory: 512Mi}
podDisruptionBudget:
enabled: true
minAvailable: 1
networkPolicy:
# Parent chart must supply this named replacement when enabled is false.
externalPolicyName: ""
enabled: true
# Kubernetes NetworkPolicy cannot allow DNS names. Production operators must
# narrow these CIDRs to their PostgreSQL/NAT destinations where supported.
apnsEgressCidrs: [0.0.0.0/0]
# Override with the actual database network. This example private range is
# intentionally separate from broad APNs HTTPS egress.
postgresEgressCidrs: [10.0.0.0/8]
dns:
namespaceSelector:
kubernetes.io/metadata.name: kube-system
podSelector:
k8s-app: kube-dns
# Scoped ingress to the private metrics port (8081). Off by default so 8081
# has no pod ingress at all; enable alongside podMonitor or an external
# annotation-discovered scraper and name its namespace/pod so reachability
# stays narrow.
monitoring:
enabled: false
namespaceSelector: {}
podSelector: {}
# Prometheus-operator PodMonitor scraping the private /metrics on port 8081.
# Off by default; requires networkPolicy.monitoring to also be enabled.
podMonitor:
enabled: false
interval: 30s
scrapeTimeout: 10s
labels: {}
# Prometheus-operator alerting rules. Off by default.
prometheusRule:
enabled: false
labels: {}
# Retryable-outcome fraction (0..1] that fires PushGatewayHighApnsRetryRate.
apnsRetryRatioThreshold: 0.25
# Minimum APNs attempts in the 10m window before the retry-ratio alert can
# fire, so a couple of retries at trivial volume cannot trip it.
apnsRetryMinSamples: 20
nodeSelector: {}
tolerations: []
affinity: {}
topologySpreadConstraints:
- maxSkew: 1
topologyKey: kubernetes.io/hostname
whenUnsatisfiable: ScheduleAnyway
labelSelector:
matchLabels:
app.kubernetes.io/name: buzz-push-gateway
# Runtime-only mesh integration. Migration settings remain separate.
podLabels: {}
serviceAccountName: ""
terminationGracePeriodSeconds: 60