open-policy-agent / Example Api Authz Go
Licence: apache-2.0
Example Go service that uses OPA for API authorization.
Stars: ✭ 37
Programming Languages
go
31211 projects - #10 most used programming language
OPA-Go API Authorization Example
This repository shows how to integrate a service written in Go with OPA to perform API authorization.
Building
Build the example by running go build ./cmd/example-api-authz-go/...
Requirements
This example requires an external HTTP server that serves OPA Bundles. If you don't provide an OPA configuration that enables bundle downloading, the server will fail-closed.
Running the example
Run the example with an OPA Configuration File:
./example-api-authz-go -config config.yaml
The example implementation is hardcoded to assume a policy decision will be generated at path
system.main
. You must define a policy decision at that
path. If your policies use another package, you can include an
entrypoint policy.
Entrypoint:
package system
main = data.example.allow
Your policy:
package example
default allow = false
allow {
input.method == "GET"
input.user == "bob"
}
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].