DEV Community

oleg makhlov
oleg makhlov

Posted on

Zero Trust for QGIS Server: Operation-Level Access Control Compliant with ISO/IEC 27001:2022

QGIS Server's built-in access control (Access Control Filters) is implemented through Python plugins. Every request passes through the Python interpreter, and due to the GIL, requests queue up under load. For a mapping service expected to deliver tiles in milliseconds, this becomes a bottleneck.

The proposed approach moves decision-making logic outside the GIS server, following NIST SP 800-207 (Zero Trust) and NIST SP 800-162 (ABAC). The architecture is built on loose coupling: independent components communicate through standard interfaces.

Benefits:

  • Separation of concerns: the GIS server only serves maps, while authorization is handled by a separate service.
  • Scalability: the authorization service is stateless (except for caching) and scales horizontally.
  • Replaceability: Keycloak can be swapped for Authentik, or OpenResty for Envoy, without changing the logic.
  • Auditability: all decisions are logged in one place.

Architecture:

  • Entry point (OpenResty): accepts the request and makes an auth_request to the authorization service.
  • Authorization service (Go): validates the JWT, verifies the signature via JWKS, and matches permissions.
  • Data source (Keycloak): issues JWTs with groups and public keys.

Permission model:
Permissions are granted not to the service as a whole, but to an operation (GetMap, GetFeature, GetTile). Since each operation belongs to a specific service (WMS, WFS, WMTS), this automatically covers service-level separation. The group hierarchy in Keycloak looks like this:

/city_roads
/GetMap
/GetFeatureInfo

In the JWT, groups arrive as a flat array of full paths. The authorization service builds targetPermission from the LAYERS and REQUEST parameters and looks it up in the token.

Technical decisions:

Two explicit requests to the data source (OIDC Discovery + JWKS) instead of keyfunc.NewDefault, which in some versions ignores TLS client settings.

Case-insensitive validation of OGC parameters: client libraries (OpenLayers, Leaflet, QGIS) may send GetMap, getmap, or GETMAP. Permissions in the token are checked against both variants.

Token caching with O(1) lookup: JWT groups are stored in a map[string]struct{} on the first request.

CORS preflight (OPTIONS) bypass in the authorization service, since auth_request in Nginx runs before the method check.

Minimal Nginx changes: auth_request /verify is added to two location blocks, plus an internal location = /verify. All logic lives in the authorization service.

This approach also satisfies ISO/IEC 27001:2022 requirements for access control (A.8.3, A.5.15): API-level authorization enforcement and centralized decision auditing.

Quick example: Nginx + Go authorization service

The entire integration comes down to two blocks in your Nginx config.

1. Protect your OGC endpoints:

_location /maps/ {
auth_request /verify;
# ... your existing proxy/QGIS config ...
}

location /qgis-server {
auth_request /verify;
# ... your existing FastCGI config ...
}_

2. Add an internal location for the authorization service:

location = /verify {
internal;
proxy_pass http://127.0.0.1:8080/verify;
proxy_pass_request_body off;
proxy_set_header Content-Length "";
proxy_set_header X-Original-URI $request_uri;
proxy_set_header Authorization $http_authorization;
}

3. In Go, the authorization service extracts the permission from the request:

_query := parsedURL.Query()
reqType := strings.ToLower(query.Get("REQUEST")) // getmap
layers := strings.ToLower(query.Get("LAYERS")) // city_roads

targetPermission := "/" + layers + "/" + reqType // /city_roads/getmap_

Then check if targetPermission exists in the JWT's groups claim (case-insensitively, to handle GetMap vs getmap).

That's it. The GIS server never sees an unauthorized request, and all decisions are logged by the authorization service.

Top comments (0)