HARP logo

Security

HARP sits between your applications and the remote APIs they call, which makes it a natural place to apply security controls without touching application code. Its rules engine runs on every request and response, so you can strip or inject headers, replace a response whole, keep secrets out of what HARP records, and block traffic that does not match your policies.

Understanding the use case

When applications talk to APIs directly, security logic ends up scattered across many codebases. Each service handles secrets, headers, and sensitive payloads its own way, which makes policies inconsistent and hard to audit. Because HARP is an API proxy on the path between your applications and remote APIs, it gives you a single point where traffic can be observed and controlled, so you enforce the same rules everywhere instead of relying on each application to get security right on its own.

What you can do with HARP

Each rule of the rules engine combines an endpoint pattern with an HTTP method and path pattern, both supporting wildcards, and runs Python at one or more lifecycle events to act on the traffic:

  • Control headers: inject the headers an upstream requires, and strip ones that expose internal details, on either the request or the response. This keeps credentials and internal details from reaching a party that does not need them.
  • Replace responses: answer with a response of your own in place of the upstream's, based on its status and headers. Rules cannot read or rewrite a body. This keeps an upstream's error pages, and what they reveal, from reaching your applications.
  • Filter unwanted traffic: pattern-match on endpoints, methods and paths to reject or short-circuit requests before they are forwarded. This keeps requests your policy forbids from reaching the upstream.
  • Encrypt in transit: between your applications and HARP, traffic is plain HTTP: HARP has no TLS setting, so put a TLS terminator in front of it when that link must be encrypted. Between HARP and the upstream API, traffic uses TLS when the remote URL is HTTPS, with certificates verified by default. TLS keeps the traffic between HARP and the API from being read or altered.
  • Keep secrets out of the record: mark a route so that HARP skips storing its headers or bodies, for example those carrying credentials. This keeps credentials out of the traffic history and the dashboard. It is an opt-out, route by route, as in the rule below.

For example, this rule runs on every endpoint and every request. It removes an internal header from the request, and marks the request headers so they are not stored:

[rules."*"."*"]
on_request = """
request.headers.popall("X-Internal-User", None)
transaction.markers.add("skip-request-headers-storage")
"""

The rule runs before HARP records the request: X-Internal-User reaches neither the upstream nor the record. The marker keeps the other request headers, Authorization included, out of the record; they still reach the upstream. Sensitive data lists every marker.

Benefits

  • Consistent policy: security logic in the proxy stays consistent and easier to review than logic spread across many applications.
  • No application changes: rules apply at the proxy, so you update policy without modifying the services that call the APIs.
  • Less sensitive data exposed: stripping headers in transit reduces what flows to upstreams (request headers) and applications (response headers) that do not need it, and skipping their storage keeps credentials out of the record.