relation

package
v0.42.0 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotExist                      = errors.New("relation doesn't exist")
	ErrInvalidUUID                   = errors.New("invalid syntax of uuid")
	ErrInvalidID                     = errors.New("relation id is invalid")
	ErrConflict                      = errors.New("relation already exist")
	ErrInvalidDetail                 = errors.New("invalid relation detail")
	ErrCreatingRelationInStore       = errors.New("error while creating relation")
	ErrCreatingRelationInAuthzEngine = errors.New("error while creating relation in authz engine")
	ErrFetchingUser                  = errors.New("error while fetching user")
)

Functions

This section is empty.

Types

type AuthzRepository

type AuthzRepository interface {
	Check(ctx context.Context, rel Relation) (bool, error)
	BatchCheck(ctx context.Context, relations []Relation) ([]CheckPair, error)
	Delete(ctx context.Context, rel Relation) error
	Add(ctx context.Context, rel Relation) error
	LookupSubjects(ctx context.Context, rel Relation) ([]string, error)
	LookupResources(ctx context.Context, rel Relation) ([]string, error)
	ListRelations(ctx context.Context, rel Relation) ([]Relation, error)
}

type CheckPair added in v0.7.4

type CheckPair struct {
	Relation Relation
	Status   bool
}

type Filter added in v0.8.8

type Filter struct {
	Subject Subject
	Object  Object
}

type Object

type Object struct {
	ID        string
	Namespace string
}

type Relation

type Relation struct {
	ID           string
	Object       Object
	Subject      Subject
	RelationName string `json:"relation_name"`

	CreatedAt time.Time
	UpdatedAt time.Time
}

type Repository

type Repository interface {
	Get(ctx context.Context, id string) (Relation, error)
	Upsert(ctx context.Context, relation Relation) (Relation, error)
	List(ctx context.Context, flt Filter) ([]Relation, error)
	DeleteByID(ctx context.Context, id string) error
	GetByFields(ctx context.Context, rel Relation) ([]Relation, error)
}

type Service

type Service struct {
	// contains filtered or unexported fields
}

func NewService

func NewService(repository Repository, authzRepository AuthzRepository) *Service

func (Service) BatchCheckPermission added in v0.7.4

func (s Service) BatchCheckPermission(ctx context.Context, relations []Relation) ([]CheckPair, error)

func (Service) CheckPermission

func (s Service) CheckPermission(ctx context.Context, rel Relation) (bool, error)

func (Service) Create

func (s Service) Create(ctx context.Context, rel Relation) (Relation, error)

func (Service) Delete

func (s Service) Delete(ctx context.Context, rel Relation) error

func (Service) Get

func (s Service) Get(ctx context.Context, id string) (Relation, error)

func (Service) GetRelationsByFields

func (s Service) GetRelationsByFields(ctx context.Context, rel Relation) ([]Relation, error)

func (Service) List

func (s Service) List(ctx context.Context, flt Filter) ([]Relation, error)

func (Service) ListRelations

func (s Service) ListRelations(ctx context.Context, rel Relation) ([]Relation, error)

ListRelations lists a set of the relationships matching filter

func (Service) LookupResources

func (s Service) LookupResources(ctx context.Context, rel Relation) ([]string, error)

LookupResources returns all the resources of a given type that a subject can access whether via a computed permission or relation membership.

func (Service) LookupSubjects

func (s Service) LookupSubjects(ctx context.Context, rel Relation) ([]string, error)

LookupSubjects returns all the subjects of a given type that have access whether via a computed permission or relation membership.

type Subject

type Subject struct {
	ID              string
	Namespace       string
	SubRelationName string `json:"subject_sub_relation"`
}

Jump to

Keyboard shortcuts

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