policy

package
v0.33.0 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotExist      = errors.New("policies doesn't exist")
	ErrInvalidUUID   = errors.New("invalid syntax of uuid")
	ErrInvalidID     = errors.New("policy id is invalid")
	ErrConflict      = errors.New("policy already exist")
	ErrInvalidDetail = errors.New("invalid policy detail")
)

Functions

This section is empty.

Types

type Filter

type Filter struct {
	OrgID     string
	ProjectID string
	GroupID   string
	RoleID    string

	PrincipalType string
	PrincipalID   string
	PrincipalIDs  []string
	ResourceType  string
}

type Filters

type Filters struct {
	UserID  string
	GroupID string
}

type MemberCount added in v0.8.8

type MemberCount struct {
	ID    string `db:"id"`
	Count int    `db:"count"`
}

type Policy

type Policy struct {
	ID            string
	RoleID        string
	ResourceID    string `json:"resource_id"`
	ResourceType  string `json:"resource_type"`
	PrincipalID   string `json:"principal_id"`
	PrincipalType string `json:"principal_type"`
	Metadata      metadata.Metadata

	CreatedAt time.Time
	UpdatedAt time.Time
}

type RelationService

type RelationService interface {
	Create(ctx context.Context, rel relation.Relation) (relation.Relation, error)
	Delete(ctx context.Context, rel relation.Relation) error
}

type Repository

type Repository interface {
	Get(ctx context.Context, id string) (Policy, error)
	List(ctx context.Context, f Filter) ([]Policy, error)
	Count(ctx context.Context, f Filter) (int64, error)
	Upsert(ctx context.Context, pol Policy) (Policy, error)
	Delete(ctx context.Context, id string) error
	GroupMemberCount(ctx context.Context, IDs []string) ([]MemberCount, error)
	ProjectMemberCount(ctx context.Context, IDs []string) ([]MemberCount, error)
	OrgMemberCount(ctx context.Context, ID string) (MemberCount, error)
}

type RoleService

type RoleService interface {
	Get(ctx context.Context, id string) (role.Role, error)
	List(ctx context.Context, f role.Filter) ([]role.Role, error)
}

type Service

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

func NewService

func NewService(repository Repository, relationService RelationService, roleService RoleService) *Service

func (Service) AssignRole

func (s Service) AssignRole(ctx context.Context, pol Policy) error

AssignRole Note: ideally this should be in a single transaction read more about how user defined roles work in spicedb https://authzed.com/blog/user-defined-roles

func (Service) Count added in v0.8.13

func (s Service) Count(ctx context.Context, f Filter) (int64, error)

func (Service) Create

func (s Service) Create(ctx context.Context, policy Policy) (Policy, error)

func (Service) Delete

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

func (Service) Get

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

func (Service) GroupMemberCount added in v0.8.8

func (s Service) GroupMemberCount(ctx context.Context, ids []string) ([]MemberCount, error)

func (Service) List

func (s Service) List(ctx context.Context, f Filter) ([]Policy, error)

func (Service) ListRoles added in v0.8.0

func (s Service) ListRoles(ctx context.Context, principalType, principalID, objectNamespace, objectID string) ([]role.Role, error)

ListRoles lists roles assigned via policies to a user

func (Service) OrgMemberCount added in v0.8.13

func (s Service) OrgMemberCount(ctx context.Context, id string) (MemberCount, error)

func (Service) ProjectMemberCount added in v0.8.8

func (s Service) ProjectMemberCount(ctx context.Context, ids []string) ([]MemberCount, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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