Triamorph Systems

Security · 13 min read · Sep 08, 2024

Zero Trust API Gateway Architecture: Designing mTLS, JWT Introspection, and Token Bucket Rate Limiting with Envoy

Architectural blueprint for Zero Trust API Gateways: Envoy proxy filter chains, mutual TLS (mTLS) with SPIFFE x509 certificates, asynchronous JWT validation, and token bucket rate limiting.

By Aman Aslam

Core Engineering Takeaways

  • Implement SPIFFE/SPIRE to issue short-lived, automatically rotated x509 SVID certificates for true service-to-service mutual TLS (mTLS).
  • Offload JWT signature validation from backend microservices to Envoy Proxy filter chains using local JWKS caching for sub-millisecond authentication.
  • Prevent distributed brute-force and DDoS attacks using Redis sliding-window token bucket algorithms running on high-speed Envoy Lua/WASM filters.

Perimeter-based security models ("castle-and-moat") are fundamentally obsolete in modern cloud environments. Once an attacker breaches a public-facing container, unencrypted internal networks allow unhindered lateral movement across microservices. A Zero Trust API Gateway assumes the network is perpetually hostile: every internal and external request must be mutually authenticated (mTLS), cryptographically authorized (JWT), and strictly rate-limited at the gateway proxy layer.

1. The Core Pillars of Zero Trust API Ingress

Why legacy perimeter firewalls fail against modern supply chain attacks

In a Zero Trust architecture, no network segment is trusted by default. Every API call—whether originating from an iPhone client or an internal billing microservice—is evaluated against explicit identity, role-based claims, and anomaly detection rules.

Gateway Auth Overhead
< 0.4ms
In-memory JWKS cryptographic verification
Certificate Lifetime
1 Hour
Automated SPIFFE rotation prevents leaks
DDoS Drop Rate
100k req/s
Kernel-level Redis rate limit filtering

2. Mutual TLS (mTLS) & Cryptographic Service Identity

Automating certificate rotation with SPIRE without restarting proxies

By leveraging Envoy’s Secret Discovery Service (SDS) integrated with SPIRE, client and server certificates are dynamically injected into active TCP connections without dropping traffic or restarting application pods.

infrastructure/envoy/zero_trust_filter.yaml (yaml)
static_resources:
  listeners:
  - name: ingress_listener
    address:
      socket_address: { address: 0.0.0.0, port_value: 443 }
    filter_chains:
    - transport_socket:
        name: envoy.transport_sockets.tls
        typed_config:
          "@type": type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.DownstreamTlsContext
          common_tls_context:
            tls_certificates:
            - certificate_chain: { filename: "/etc/envoy/certs/server.crt" }
              private_key: { filename: "/etc/envoy/certs/server.key" }
      filters:
      - name: envoy.filters.network.http_connection_manager
        typed_config:
          "@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
          stat_prefix: ingress_http
          http_filters:
          - name: envoy.filters.http.jwt_authn
            typed_config:
              "@type": type.googleapis.com/envoy.extensions.filters.http.jwt_authn.v3.JwtAuthentication
              providers:
                auth0_provider:
                  issuer: https://auth.triamorphsystems.com/
                  audiences:
                  - api://enterprise-core
                  remote_jwks:
                    http_uri:
                      uri: https://auth.triamorphsystems.com/.well-known/jwks.json
                      cluster: jwks_cluster
                      timeout: 1s
                    cache_duration: 300s
          - name: envoy.filters.http.router
            typed_config:
              "@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router

3. High-Speed Envoy JWT Authentication Filters

Offloading token cryptography before requests hit application code

Envoy validates RSA256 and Ed25519 JWT signatures in C++, parsing claims (e.g. `tenant_id`, `roles`, `sub`) and forwarding them as sanitized internal headers (`X-Tenant-Id`, `X-User-Role`) to upstream microservices.

4. Redis Sliding Window & Token Bucket Rate Limiting

Granular multi-tier rate limiting per IP, API key, and tenant tier

By connecting Envoy’s Global Rate Limit Service (RLS) to a Redis cluster, rate limits are enforced across thousands of gateway nodes simultaneously, preventing noisy neighbors from consuming shared API capacity.

Tags: zero trust api gateway architecturemtls service to service authentication envoyjwt introspection api gatewaytoken bucket rate limiting redisenterprise api security best practices

Related Engineering Practice & Case Studies

Engineering Practice Blueprint

Custom Desktop Software & Security Engineering →

Air-gapped offline-first software, zero-trust architectures, and cryptographic integrity.

View Practice Blueprint & Capabilities →
Production Client System

Portfolix Developer Portfolio Builder →

Modern developer portfolio builder platform delivering sub-5 minute deployments with 98+ Lighthouse scores and 100% clean code export.

Read Deployed Case Study (Sub-5 minute edge deployment with 100% clean code export) →

Related Engineering Articles & Guides

Explore all technical guides in our Articles & Guides Index → or discuss your architecture with our engineers via Technical Discovery →