query

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package query provides the client for querying spicedb

Index

Constants

View Source
const (
	// ApplicationPrefix is the prefix for all application IDs owned by permissions-api
	ApplicationPrefix string = "perm"
	// RolePrefix is the prefix for roles
	RolePrefix string = ApplicationPrefix + "rol"
)

Variables

View Source
var (
	// ErrActionNotAssigned represents an error condition where the subject is not able to complete
	// the given request.
	ErrActionNotAssigned = errors.New("the subject does not have permissions to complete this request")

	// ErrInvalidReference represents an error condition where a given SpiceDB object reference is for some reason invalid.
	ErrInvalidReference = errors.New("invalid reference")

	// ErrInvalidNamespace represents an error when the id prefix is not found in the resource schema
	ErrInvalidNamespace = errors.New("invalid namespace")

	// ErrInvalidType represents an error when a resource type is not found in the resource schema
	ErrInvalidType = errors.New("invalid type")

	// ErrInvalidRelationship represents an error when no matching relationship was found
	ErrInvalidRelationship = errors.New("invalid relationship")

	// ErrRoleNotFound represents an error when no matching role was found on resource
	ErrRoleNotFound = errors.New("role not found")

	// ErrRoleHasTooManyResources represents an error which a role has too many resources
	ErrRoleHasTooManyResources = errors.New("role has too many resources")
)

Functions

This section is empty.

Types

type Engine

type Engine interface {
	AssignSubjectRole(ctx context.Context, subject types.Resource, role types.Role) (string, error)
	UnassignSubjectRole(ctx context.Context, subject types.Resource, role types.Role) (string, error)
	CreateRelationships(ctx context.Context, rels []types.Relationship) (string, error)
	CreateRole(ctx context.Context, res types.Resource, actions []string) (types.Role, string, error)
	GetRole(ctx context.Context, roleResource types.Resource, queryToken string) (types.Role, error)
	GetRoleResource(ctx context.Context, roleResource types.Resource, queryToken string) (types.Resource, error)
	ListAssignments(ctx context.Context, role types.Role, queryToken string) ([]types.Resource, error)
	ListRelationshipsFrom(ctx context.Context, resource types.Resource, queryToken string) ([]types.Relationship, error)
	ListRelationshipsTo(ctx context.Context, resource types.Resource, queryToken string) ([]types.Relationship, error)
	ListRoles(ctx context.Context, resource types.Resource, queryToken string) ([]types.Role, error)
	DeleteRelationships(ctx context.Context, relationships ...types.Relationship) (string, error)
	DeleteRole(ctx context.Context, roleResource types.Resource, queryToken string) (string, error)
	DeleteResourceRelationships(ctx context.Context, resource types.Resource) (string, error)
	NewResourceFromID(id gidx.PrefixedID) (types.Resource, error)
	GetResourceType(name string) *types.ResourceType
	SubjectHasPermission(ctx context.Context, subject types.Resource, action string, resource types.Resource) error
}

Engine represents a client for making permissions queries.

func NewEngine

func NewEngine(namespace string, client *authzed.Client, options ...Option) Engine

NewEngine returns a new client for making permissions queries.

type Option added in v0.1.4

type Option func(*engine)

Option is a functional option for the engine

func WithLogger added in v0.1.4

func WithLogger(logger *zap.SugaredLogger) Option

WithLogger sets the logger for the engine

func WithPolicy added in v0.1.4

func WithPolicy(policy iapl.Policy) Option

WithPolicy sets the policy for the engine

type Stores

type Stores struct {
	SpiceDB       *authzed.Client
	SpiceDBPrefix string
}

Stores represents a SpiceDB store.

Directories

Path Synopsis
Package mock contains a mock implementation of the query.Engine interface.
Package mock contains a mock implementation of the query.Engine interface.

Jump to

Keyboard shortcuts

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