How google/fhir-gateway works
Main Components
• Core Proxy Server (the “server” module): Implements the core functionality of receiving FHIR requests, validating JWT tokens, applying access control logic (via access-checkers) and forwarding queries to the FHIR store.
• Access-Checker Plugins (the “plugins” module): These encapsulate the per-request authorization logic. There are sample plugins (e.g., for checking patient or list-based authorization) that can be dynamically loaded into the proxy.
• Executable Application (the “exec” module): Provides a complete Spring Boot application that packages the proxy server and access-checker plugins together so that they can be run as an executable jar.
• Configuration & Environment: Includes configuration parameters (environment variables) like PROXY_TO, TOKEN_ISSUER, ACCESS_CHECKER, and BACKEND_TYPE that dictate runtime behavior and integration with external services.
• External FHIR Data Store: An external FHIR server or store (such as HAPI FHIR or GCP FHIR store) that the proxy forwards validated queries to.
• Identity Provider/Authorization Server (IDP/AuthZ): Although not implemented within this project, it is a critical external component that issues access tokens (JWT) which the proxy validates.
• Docker & CI/CD Components: Dockerfiles, GitHub workflows, and related scripts indicate that the system is designed to be deployed in containers and built using CI/CD pipelines.
Architectural Relationships and Data Flow
• Requests originate from the client (e.g., a FHIR client application) and target the FHIR Gateway.
• The gateway first verifies the presence and validity of a Bearer access token. This token’s claims are used by the access-checker plugins.
• Depending on the token’s contents (e.g., “patient_list” or “patient_id”), the appropriate plugin in the plugins module evaluates whether to allow or deny the request.
• If approved, the proxy (server module) forwards the request to the designated backend FHIR store (which can be HAPI, GCP, etc.).
• The response from the FHIR store is relayed back through the gateway to the client.
• Optional components include using Docker images, service accounts (for GCP), and other security configurations that tie into the deployment and operational environment.
Architectural Patterns and Design Principles
• Modular Design: The separation of the core proxy logic (server) from the access-checker plugins (plugins) offers extensibility and separation of concerns.
• Layered Architecture: There are distinct layers including the HTTP interface (Spring Boot Web layer), application/service layer (authentication & access control logic), and integration layer (communication with external FHIR servers).
• Dependency Injection and Component Scanning: The project leverages Spring Boot (especially in the exec module) to automatically discover and wire up components, such as the automatic detection of plugins via @ComponentScan.
• Proxy Pattern: The application functions as an intermediary, securing and routing communication between FHIR clients and the underlying FHIR datastore.
Relevant Technologies, Frameworks, and Tools
• Java & Maven: The project follows a standard Java project structure with multiple Maven modules (server, plugins, exec, etc.).
• Spring Boot: Used primarily in the “exec” module to simplify server setup and dependency management.
• Docker: Provided Dockerfiles and Docker Compose files indicate containerization for deployment.
• CI/CD Tools: GitHub workflows (such as CodeQL and Codecov) for automated testing and security analysis.
• HAPI FHIR: The proxy is built on a HAPI FHIR Plain Server, one of the popular FHIR server frameworks.