Small Go service. It speak AuthZEN. It ask OpenFGA: "Can user do thing?"
- PDP: answer yes/no access.
- PAP: read, grant, and revoke role tuples.
- OpenFGA: hold the real auth model and tuples.
- Go
- Docker
- OpenFGA, easiest with Docker Compose
Start OpenFGA:
docker compose up openfgaMake config.json in repo root. Git ignore this file, good place for local IDs:
{
"api_url": "http://localhost:8080",
"store_id": "<store-id>",
"authorization_model_id": "<model-id>"
}OpenFGA store must have model from openfga/samples/model.fga.
Run API:
make runWith make run:
- public API at
http://localhost:8081 - private API at
http://localhost:8090 - OpenFGA at
http://localhost:8080
Public interface is for north-south callers behind the edge authentication layer.
- Every public route requires authentication.
- Default auth uses
X-Auth-Request-Emailfrom the trusted edge. - JWT auth can be selected with
--public-auth-strategy jwt --jwt-secret <secret>. - PAP search/grant/revoke checks if the authenticated user can read or edit roles on resource.
Example:
curl -sS http://localhost:8081/.well-known/authzen-configuration \
-H 'X-Auth-Request-Email: alice@example.com'Private interface trust caller. It exposes PDP and PAP with no extra guard.
Use it only for local dev, tests, and trusted inside network.
curl -sS http://localhost:8090/.well-known/authzen-pap-configurationPDP paths:
GET /.well-known/authzen-configurationPOST /v1/access/evaluationPOST /v1/access/evaluationsPOST /v1/search/subjectPOST /v1/search/resourcePOST /v1/search/action
PAP paths:
GET /.well-known/authzen-pap-configurationPOST /v1/assignment/actionPOST /v1/search/assignmentPOST /v1/assignment/grantPOST /v1/assignment/revoke
curl -sS http://localhost:8081/v1/access/evaluation \
-H 'X-Auth-Request-Email: alice@example.com' \
-H 'Content-Type: application/json' \
-d '{
"subject": {"type": "user", "id": "alice"},
"action": {"name": "can_delete"},
"resource": {"type": "namespace", "id": "payments"}
}'Good answer shape:
{
"decision": true
}Bad access is still normal answer:
{
"decision": false
}make build
make test
make lint
make fmt
make vet
make tidyPublic authentication flags:
--public-auth-strategy trusted-header
--trusted-header-name X-Auth-Request-Email
--public-auth-strategy jwt --jwt-claim email --jwt-secret <secret>REST Client examples live in http/*.http.
config.jsonhas local store IDs. Do not commit it.http/pap.httpcan change OpenFGA tuples.- Private port has sharp rocks. Do not expose to world.