This repository shows how to integrate a http service written in Gin with the OPA to perform API authorization.
make
make run
or go run main.go
test opa:
- None resource request is allowed,
curl http://localhost:8080/
- Unauthenticated user is not allowed for api resource,
curl http://localhost:8080/api/users
- Authenticated user get resource is allowed,
curl http://localhost:8080/api/users?user=bob
Authentication rego config in (authz.rego)[./authz/authz.rego]
Gin middleware code in server.go