How gematik/zero-lab works
Project Type and Purpose
• This is a Go‑based suite of micro‑services and libraries that together implement Zero Trust security primitives: client registration, attestation (Android Key/ID, Apple DCAppAttest, TPM), DPoP, OpenID Federation (OIDF) relying party, Nonce service, and a Policy Enforcement Point (PEP). It includes both server components (authorization server, PEP, reverse‑proxy plugin) and client‑side tooling (CLI commands, static web assets, libzero library).
High‑Level File‑Structure Analysis
• go/authzserver: The Registration & Authorization server with HTTP endpoints under /reg (nonce, auth, registrations, challenges, clients, cert issuance).
• go/cmd: Stand‑alone executables:
• zero‑zerobin: a demo “zerobin” web service (static UI + DPoP flows).
• zero: CLI for identity, registration, TPM, tcl interactions.
• go/libzero: Shared library of security primitives (attestation, nonce, DPoP, OAuth2/OIDC/OIDF, registration API, tcl, util, webclient).
• go/pep: Policy Enforcement Point service—HTTP reverse‑proxy with pattern‑based routing.
• go/zaddy: Caddy plugin (“zero‑caddy”) that enforces PEP policies in Caddy server.
• go/vau: Encryption/Key‑exchange service (EC‑Diffie‑Hellman, KEM) for protecting data in transit.
• static/: Static assets (images). temp/: Scratch code & OpenAPI specs.
README Insights
• Implements ACME‑style registration with nonces, JWS, JWK, MTLS certificates.
• Supports multi‑format attestation (Android, Apple, TPM).
• Exposes REST endpoints for each registration step and certificate issuance.
• PEP evolves through iterations—initial reverse proxy, then JWT self‑contained tokens, DPoP & nonce support, PoP‑token verification.
a. Components to include
1. Client App (mobile or browser)
– Contains libzero for nonce, DPoP, attestation, JWK/MTLS key management.
2. Registration & Authorization Server (go/authzserver)
– Nonce Service, Registration API (/reg/*), Certificate issuance.
3. Policy Enforcement Point (go/pep or go/zaddy + Caddy)
– Routes incoming app/API traffic, adds/validates X-ZTA- headers.
4. Reverse‑Proxy (Caddy + zero‑caddy plugin)
5. Demo “zerobin” Web Service (go/cmd/zero‑zerobin)
6. VAU Encryption Service (go/vau)
7. External Identity Providers
– GesundheitsID (OpenID Connect)
– Federated IDPs via OIDF
8. Optional CLI Tools (go/cmd/zero)
9. Shared Library (go/libzero)
10. Static Web Client UI (go/libzero/webclient + go/cmd/zero‑zerobin/static)
b. Relationships & Data Flows
1. Client → PEP/Proxy: initial REST calls (GET nonce, POST JWS‑protected payload).
2. PEP → AuthZ Server: forwards requests to /reg endpoints.
3. AuthZ Server ↔ Nonce Service (internal) for nonce issuance/validation.
4. AuthZ Server ↔ External IDP (OIDC/OIDF) for subject authentication.
5. AuthZ Server → Certificate Authority (built‑in CA in libzero/ca) for MTLS cert issuance.
6. Client → Demo Zerobin Service (for DPoP‑protected endpoints).
7. VAU Service invoked by AuthZ or other services for data encryption/attestation flows.
c. Architectural Patterns & Principles
• Micro‑services (each go/* module can run independently).
• ACME‑style registration: Nonce + JWS + JWK + GET‑over‑POST.
• Plugin architecture (zero‑caddy for Caddy).
• Library‑driven reuse (libzero).
• Zero Trust: no implicit trust, continuous attestation, per‑request verification.
d. Key Technologies & Frameworks
• Go modules & CLI (go/cmd)
• HTTP server (net/http, Echo middleware in libzero/dpop)
• JSON Web Signature (JWS), JOSE, JSON Web Key (JWK)
• DPoP (RFC 9449)
• TPM & DCAppAttest libraries
• OpenID Connect (OAuth2 + OIDF)
• Caddy web server + plugin (zaddy)
• Docker (Dockerfiles in cmd subfolders)
Key Elements to Capture
• Nonce issuance & validation service inside AuthZ
• Attestation formats and where they’re plugged in (Android, Apple, TPM)
• OpenID/OIDF interactions for subject identity
• ACME‑style GET‑over‑POST JWS flows
• Policy Enforcement Point placement (edge proxy)