A go library for interacting with OpenFGA - it is comprised of 2 packages, fgax
and entfga
.
- fgax: wrapper to interact with the OpenFGA go-sdk and client libraries
- entfga: an ent extension to create relationship tuples using ent Hooks
You can install fgax
by running the following command:
go get github.com/theopenlane/fgax@latest
This package includes helper functions used heavily in OpenLane.
For example, you can easily check for Read
access of an organization using
// create client
fgaClient, err := fgax.Client("https://fga-host.example.com")
if err != nil {
return false
}
// create access check
req := fgax.AccessCheck{
SubjectID: "user-id",
SubjectType: "user",
ObjectID: "organization-id",
}
allow, err := fgaClient.CheckOrgReadAccess(ctx, req)
if err != nil {
return false
}
See the README for details
Please read the contributing guide.