Documentation
¶
Overview ¶
Package openfga provides an OpenFGA-based Authorizer implementation for pkg/authz. Use NewAuthorizer to create an instance and pass it to authz.Server().
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewAuthorizer ¶
func NewAuthorizer(fgaClient *pkgfga.Client, opts ...Option) authz.Authorizer
NewAuthorizer creates an OpenFGA-backed Authorizer. The fgaClient must not be nil; pass WithRedisCache to enable result caching.
Types ¶
type Authorizer ¶
type Authorizer struct {
// contains filtered or unexported fields
}
Authorizer is an OpenFGA-based authorization engine. It optionally caches results in Redis via the WithRedisCache option.
func (*Authorizer) IsAuthorized ¶
func (a *Authorizer) IsAuthorized(ctx context.Context, subject, relation, objectType, objectID string) (bool, error)
IsAuthorized checks whether subject has the given relation on objectType:objectID. If a Redis cache is configured, results are cached for the configured TTL. The CacheHit field in DecisionDetail reflects whether the result came from cache.
Click to show internal directories.
Click to hide internal directories.