group

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Enabled  State = "enabled"
	Disabled State = "disabled"

	AdminPermission = schema.DeletePermission

	MemberRole = schema.GroupMemberRole
	AdminRole  = schema.GroupOwnerRole
)

Variables

View Source
var (
	ErrNotExist              = errors.New("group doesn't exist")
	ErrInvalidUUID           = errors.New("invalid syntax of uuid")
	ErrInvalidID             = errors.New("group id is invalid")
	ErrConflict              = errors.New("group already exist")
	ErrInvalidDetail         = errors.New("invalid group detail")
	ErrListingGroupRelations = errors.New("error while listing relations")
	ErrFetchingUsers         = errors.New("error while fetching users")
	ErrFetchingGroups        = errors.New("error while fetching groups")
)

Functions

This section is empty.

Types

type AuthnService

type AuthnService interface {
	GetPrincipal(ctx context.Context, via ...authenticate.ClientAssertion) (authenticate.Principal, error)
}

type Filter

type Filter struct {
	SU bool // super user

	OrganizationID  string
	State           State
	WithMemberCount bool

	GroupIDs []string
}

type Group

type Group struct {
	ID             string
	Name           string
	Title          string
	OrganizationID string `json:"orgId"`
	Metadata       metadata.Metadata
	State          State
	CreatedAt      time.Time
	UpdatedAt      time.Time

	// Transient fields
	MemberCount int
}

type PolicyService added in v0.7.5

type PolicyService interface {
	Create(ctx context.Context, policy policy.Policy) (policy.Policy, error)
	List(ctx context.Context, flt policy.Filter) ([]policy.Policy, error)
	Delete(ctx context.Context, id string) error
	GroupMemberCount(ctx context.Context, ids []string) ([]policy.MemberCount, error)
}

type RelationService

type RelationService interface {
	Create(ctx context.Context, rel relation.Relation) (relation.Relation, error)
	ListRelations(ctx context.Context, rel relation.Relation) ([]relation.Relation, error)
	LookupSubjects(ctx context.Context, rel relation.Relation) ([]string, error)
	LookupResources(ctx context.Context, rel relation.Relation) ([]string, error)
	Delete(ctx context.Context, rel relation.Relation) error
}

type Repository

type Repository interface {
	Create(ctx context.Context, grp Group) (Group, error)
	GetByID(ctx context.Context, id string) (Group, error)
	GetByIDs(ctx context.Context, groupIDs []string, flt Filter) ([]Group, error)
	List(ctx context.Context, flt Filter) ([]Group, error)
	UpdateByID(ctx context.Context, toUpdate Group) (Group, error)
	ListGroupRelations(ctx context.Context, objectId, subjectType, role string) ([]relation.Relation, error)
	SetState(ctx context.Context, id string, state State) error
	Delete(ctx context.Context, id string) error
}

type Service

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

func NewService

func NewService(repository Repository, relationService RelationService,
	authnService AuthnService, policyService PolicyService) *Service

func (Service) AddMember

func (s Service) AddMember(ctx context.Context, groupID string, principal authenticate.Principal) error

AddMember adds a subject(user) to group as member

func (Service) AddUsers

func (s Service) AddUsers(ctx context.Context, groupID string, userIDs []string) error

func (Service) Create

func (s Service) Create(ctx context.Context, grp Group) (Group, error)

func (Service) Delete

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

func (Service) Disable

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

func (Service) Enable

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

func (Service) Get

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

func (Service) GetByIDs added in v0.7.6

func (s Service) GetByIDs(ctx context.Context, ids []string) ([]Group, error)

func (Service) List

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

func (Service) ListByOrganization

func (s Service) ListByOrganization(ctx context.Context, id string) ([]Group, error)

ListByOrganization will be useful for nested groups but we don't do that at the moment so it will not be directly used

func (Service) ListByUser

func (s Service) ListByUser(ctx context.Context, principalID, principalType string, flt Filter) ([]Group, error)

func (Service) RemoveUsers

func (s Service) RemoveUsers(ctx context.Context, groupID string, userIDs []string) error

RemoveUsers removes users from a group as members

func (Service) Update

func (s Service) Update(ctx context.Context, grp Group) (Group, error)

type State

type State string

func (State) String

func (s State) String() string

Jump to

Keyboard shortcuts

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