MATIH Platform is in active MVP development. Documentation reflects current implementation status.
8. Platform Services
Plugins

Plugins

The API Gateway supports a plugin system through Kong's plugin architecture. Plugins can be enabled globally, per-service, or per-route. The GatewayManagementService provides endpoints to enable, disable, and configure plugins dynamically at runtime.


Plugin Configuration

PluginConfig Properties

PropertyTypeDefaultDescription
idStringauto-generatedPlugin instance ID
pluginNameStringrequiredKong plugin name
serviceNameStringnullScope to a specific service
routeNameStringnullScope to a specific route
enabledbooleantrueWhether the plugin is active
configMapnullPlugin-specific configuration

Plugin Scoping

Plugins can be applied at three levels:

ScopeBehavior
GlobalApplies to all routes and services (neither serviceName nor routeName set)
ServiceApplies to all routes of a specific service (serviceName set)
RouteApplies to a specific route only (routeName set)

Enable a Plugin

Endpoint: POST /api/v1/gateway/plugins

Global Plugin

curl -X POST http://localhost:8080/api/v1/gateway/plugins \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer ${TOKEN}" \
  -d '{
    "pluginName": "cors",
    "enabled": true,
    "config": {
      "origins": ["*"],
      "methods": ["GET", "POST", "PUT", "DELETE", "OPTIONS"],
      "headers": ["Authorization", "Content-Type", "X-Tenant-ID"],
      "max_age": 3600
    }
  }'

Service-Scoped Plugin

curl -X POST http://localhost:8080/api/v1/gateway/plugins \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer ${TOKEN}" \
  -d '{
    "pluginName": "request-size-limiting",
    "serviceName": "ai-service",
    "enabled": true,
    "config": {
      "allowed_payload_size": 10,
      "size_unit": "megabytes"
    }
  }'

Route-Scoped Plugin

curl -X POST http://localhost:8080/api/v1/gateway/plugins \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer ${TOKEN}" \
  -d '{
    "pluginName": "response-transformer",
    "routeName": "bi-service-route",
    "enabled": true,
    "config": {
      "add": {
        "headers": ["X-Cache-Status:MISS"]
      }
    }
  }'

Update Plugin Configuration

Endpoint: PATCH /api/v1/gateway/plugins/:pluginId

curl -X PATCH http://localhost:8080/api/v1/gateway/plugins/abc-123 \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer ${TOKEN}" \
  -d '{
    "origins": ["https://app.matih.ai", "https://admin.matih.ai"],
    "max_age": 7200
  }'

Disable a Plugin

Endpoint: DELETE /api/v1/gateway/plugins/:pluginId

curl -X DELETE http://localhost:8080/api/v1/gateway/plugins/abc-123 \
  -H "Authorization: Bearer ${TOKEN}"

Common Plugins

PluginPurposeTypical Scope
corsCross-origin resource sharingGlobal
advanced-rate-limiterPer-tenant rate limitingGlobal / Service
jwtJWT token validationGlobal
request-size-limitingLimit request payload sizeService
response-transformerModify response headers/bodyRoute
request-transformerModify request headers/bodyRoute
traffic-mirrorMirror traffic to shadow serviceRoute
ip-restrictionAllow/deny by IP addressService / Route
bot-detectionDetect and block botsGlobal
correlation-idAdd correlation ID headersGlobal
prometheusExport Prometheus metricsGlobal

Plugin Execution Order

Kong plugins execute in a defined order based on plugin priority. The execution order for common plugins is:

  1. correlation-id (add request tracking)
  2. ip-restriction (block disallowed IPs)
  3. bot-detection (block bots)
  4. jwt (authenticate)
  5. advanced-rate-limiter (enforce rate limits)
  6. request-transformer (modify request)
  7. request-size-limiting (validate payload)
  8. Proxy to upstream
  9. response-transformer (modify response)
  10. prometheus (record metrics)

Plugin configuration is stored in Kong's internal database. The gateway management API acts as a wrapper around the Kong Admin API for programmatic control. All plugin changes take effect within seconds without requiring a gateway restart.