authz

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 1, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthzError

type AuthzError struct {
	// Op is the operation that caused the error.
	Op string
	// Err is the error that occurred.
	Err error
}

AuthzError is an error that occurred while executing a query.

func NewQueryError

func NewQueryError(op string, err error) *AuthzError

NewQueryError returns a new QueryError.

func (*AuthzError) Error

func (e *AuthzError) Error() string

Error implements the error interface.

func (*AuthzError) Unwrap

func (e *AuthzError) Unwrap() error

Unwrap implements the errors.Wrapper interface.

type Object

type Object string

Object is the object that is being accessed.

type Relation

type Relation string

Relation is the relation between the user and the object.

type Store

type Store[Tx any] interface {
	// Allowed checks if the user is allowed to perform the operation on the object.
	Allowed(context.Context, User, Object, Relation) (bool, error)
	// WriteTx starts a read write transaction.
	WriteTx(context.Context, func(context.Context, Tx) error) error
}

Store is an interface that provides methods for transactional operations on the authz database.

func NewStore

func NewStore[Tx any](client *client.OpenFgaClient, tx StoreTxFactory[Tx]) (Store[Tx], error)

NewStore returns a new instance of authz store.

type StoreTx

type StoreTx interface {
	// WriteTuple writes a tuple to the authz database.
	WriteTuple(context.Context, User, Object, Relation) error
	// DeleteTuple deletes a tuple from the authz database.
	DeleteTuple(context.Context, User, Object, Relation) error
}

StoreTx is an interface that provides methods for transactional operations on the authz database.

type StoreTxFactory

type StoreTxFactory[Tx any] func(*client.OpenFgaClient, StoreTx) (Tx, error)

StoreTxFactory is a function that creates a new instance of authz store.

type User

type User string

User is the user that is making the request.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL