This app is the Gateway Verifier for the NVI and PRS and is part of the 'Generieke Functies, lokalisatie en addressering' project of the Ministry of Health, Welfare and Sport of the Dutch government. This repository contains a FastAPI service that validates protected gateway requests using a bearer JWT and the acting identity supplied by the gateway.
Caution
This project and all associated code serve solely as documentation and demonstration purposes to illustrate potential system communication patterns and architectures.
This codebase:
- Is NOT intended for production use
- Does NOT represent a final specification
- Should NOT be considered feature-complete or secure
- May contain errors, omissions, or oversimplified implementations
- Has NOT been tested or hardened for real-world scenarios
The code examples are only meant to help understand concepts and demonstrate possibilities.
By using or referencing this code, you acknowledge that you do so at your own risk and that the authors assume no liability for any consequences of its use.
In production, Kong processes a protected request in this order:
- The
cert-infoKong plugin injectsX-GF-Act-SubandX-GF-Act-Cn. - The
gateway-verifierKong plugin requires a bearer token and those acting identity headers, then calls the configured Gateway Verifier FastAPI service's/validateendpoint through itsverifier_url. - The service validates the JWT and checks that
act.subandact.cnmatch the supplied acting values. It does not perform certificate validation. - On a
200response, thegateway-verifierplugin injects the returnedx-gf-*identity values into the upstream request and Kong continues to the backend.
The Gateway Verifier service is deployed once for NVI and once for PRS. The
corresponding gateway-verifier Kong plugin configuration points verifier_url
to that deployment. A non-200 response from the service is returned by the
plugin as 401; a connection failure or an invalid JSON response from the
service becomes 502.
The Gateway Verifier service:
- Requires
Authorization: Bearer <token>,X-GF-Act-Sub, andX-GF-Act-Cn - Validates JWT signature and claims (
iss,aud,exp,nbf,iat) against configured issuer/audience and JWKS - Requires JWT
act.subandact.cnto matchX-GF-Act-SubandX-GF-Act-Cn
On success, /validate returns these identity values as JSON:
x-gf-cert-typex-gf-audiencex-gf-scopex-gf-subx-gf-act-subx-gf-act-cnx-gf-organization-namex-gf-client-idx-gf-source-id(when the signedsource_idclaim has a value)
For local development, where Kong is not handling verification, the
development-only /proxy endpoint simulates the gateway-verifier Kong plugin
by validating the request, setting the verified x-gf-* identity headers, and
forwarding the request. See docs/kong.md for its behavior.
GET /ASCII home page with service logo and version details (whenversion.jsonexists)GET /version.jsonraw version metadata (404when missing)GET /healthservice health responseGET /validatevalidates the bearer JWT and acting identity headers, then returns identity values as JSON- Development-only:
GET|POST|PUT|PATCH|DELETE /proxyand/proxy/{upstream_path:path}validate and forward requests tokong_proxy.urlwhen enabled - Development-only:
GET|POST|PUT|PATCH|DELETE /proxy/healthprovides an unauthenticated backend health passthrough
See docs/kong.md for development proxy details.
You can run this service natively or with Docker.
If you run Linux, export your user and group IDs so mounted files keep correct ownership:
export NEW_UID=$(id -u)
export NEW_GID=$(id -g)Start the service:
docker compose upThe service port is configured in app.conf / app.conf.example (8503 by default).
Install dependencies and run with Poetry:
poetry install
poetry run python -m app.mainThe gateway-verifier Kong plugin calls /validate after the cert-info Kong
plugin has set X-GF-Act-Sub and X-GF-Act-Cn. The endpoint can also be called
directly for local testing:
curl -i http://localhost:8503/validate \
-H "Authorization: Bearer <jwt>" \
-H "X-GF-Act-Sub: <jwt-act-sub>" \
-H "X-GF-Act-Cn: <jwt-act-cn>"In a direct request, supply the acting headers manually with values matching the
JWT act.sub and act.cn claims.
Expected direct service responses:
200for a valid JWT with matching acting identity values400for JWT verification failures, required claim failures, or acting identity mismatches401for a malformed non-BearerAuthorizationheader500when required gateway headers are missing
Default image build:
make container-buildStandalone image build (uses docker/init-standalone.sh, expects mounted app.conf):
make container-build-saDocker images are published to the GitHub Container Registry
You can pull the latest image with the following command:
docker pull ghcr.io/minvws/gfmodules-nationale-verwijsindex-gateway-verifier:latestAs stated in the disclaimer this project and all associated code serve solely as documentation and demonstration purposes to illustrate potential system communication patterns and architectures.
For that reason we will only accept contributions that fit this goal. We do appreciate any effort from the community, but because our time is limited it is possible that your PR or issue is closed without a full justification.
If you plan to make non-trivial changes, we recommend to open an issue beforehand where we can discuss your planned changes. This increases the chance that we might be able to use your contribution (or it avoids doing work if there are reasons why we wouldn't be able to use it).
Note that all commits should be signed using a gpg key.
To keep local editor/IDE files out of version control, configure a global ignore file:
git config --global core.excludesfile ~/.gitignore