Expand description
Open Policy Agent authorization plugin (opa).
Delegates the access decision for each request to an external OPA server.
The plugin builds an OPA input document describing the request (and,
optionally, the matched consumer), POSTs it to
<host>/v1/data/<policy>, and interprets the decision under result:
allow: true continues (optionally copying selected OPA-provided headers
onto the request forwarded upstream), while allow: false/missing rejects,
honoring OPA-supplied status, headers, and reason. A callout or
response-parse failure blocks the request by default.
Ports the APISIX opa plugin (and its opa/helper.lua input builder) onto
featherbit’s shared outbound HTTP client.
§Deviations from APISIX
featherbit has no route/service objects, so with_route and with_service
are accepted for config compatibility but are no-ops (no route /
service object is added to the input document). The input var block
omits server_addr / server_port, which featherbit does not track in the
request context.
Structs§
- OpaDecision 🔒
- A parsed OPA decision (the
resultobject of the response). - OpaPlugin
- Sends an OPA input document to an external policy server and routes on the
returned decision:
allow: truecontinues (success port), otherwise rejects (error port).
Enums§
- OpaParse
Error 🔒 - Why an OPA response could not be interpreted as a decision.
Functions§
- build_
consumer 🔒 - Builds the
consumerobject fromcontext.message’sconsumer.*keys, stripping the prefix. ReturnsNonewhen no consumer is attached. - collapse_
multi 🔒 - Collapses a multi-valued header/query map into single strings where there
is one value and arrays where there are several — mirroring OpenResty’s
core.request.headers/get_uri_argsshape. - parse_
opa_ 🔒response - Parses an OPA response body into an
OpaDecision. Pure and network-free so the decision-mapping logic is unit-testable. - split_
addr_ 🔒port - Splits a client
ip:portinto(ip, port), tolerating bare IPs and bracketed IPv6. - split_
host_ 🔒port - Splits a
Hostheader into(hostname, port), defaulting the port from the scheme when the host carries none.