Documentation ¶
Index ¶
- Variables
- func FlagDictionary() map[uint32]string
- type Asset
- type AssetKind
- type CassandraStore
- func (c CassandraStore) CreateRelation(ctx context.Context, rel Relation) error
- func (c CassandraStore) DeleteByID(ctx context.Context, groupID uuid.UUID) error
- func (c CassandraStore) DeleteRelation(ctx context.Context, rel Relation) error
- func (c CassandraStore) FetchAllGroups(ctx context.Context) (gs []Group, err error)
- func (c CassandraStore) FetchAllRelations(ctx context.Context) ([]Relation, error)
- func (c CassandraStore) FetchGroupByID(ctx context.Context, groupID uuid.UUID) (g Group, err error)
- func (c CassandraStore) FetchGroupByKey(ctx context.Context, key string) (g Group, err error)
- func (c CassandraStore) FetchGroupByName(ctx context.Context, name string) (g Group, err error)
- func (c CassandraStore) FetchGroupRelations(ctx context.Context, groupID uuid.UUID) ([]Relation, error)
- func (c CassandraStore) FetchGroupsByName(ctx context.Context, isPartial bool, name string) (gs []Group, err error)
- func (c CassandraStore) HasRelation(ctx context.Context, rel Relation) (bool, error)
- func (c CassandraStore) UpsertGroup(ctx context.Context, g Group) (Group, error)
- type Flags
- type Group
- type List
- type Manager
- func (m *Manager) Create(ctx context.Context, flags Flags, parentID uuid.UUID, key string, name string) (g Group, err error)
- func (m *Manager) CreateRelation(ctx context.Context, rel Relation) (err error)
- func (m *Manager) DeleteGroup(ctx context.Context, groupID uuid.UUID) (err error)
- func (m *Manager) DeleteRelation(ctx context.Context, rel Relation) (err error)
- func (m *Manager) GroupByID(ctx context.Context, id uuid.UUID) (g Group, err error)
- func (m *Manager) GroupByKey(ctx context.Context, key string) (g Group, err error)
- func (m *Manager) GroupByName(ctx context.Context, name string) (g Group, err error)
- func (m *Manager) Groups(ctx context.Context, mask Flags) []Group
- func (m *Manager) GroupsByAssetID(ctx context.Context, mask Flags, asset Asset) (gs []Group)
- func (m *Manager) Init(ctx context.Context) error
- func (m *Manager) Invite(ctx context.Context, groupID uuid.UUID, asset Asset) (err error)
- func (m *Manager) IsAsset(ctx context.Context, groupID uuid.UUID, asset Asset) bool
- func (m *Manager) IsCircuited(ctx context.Context, groupID uuid.UUID) (bool, error)
- func (m *Manager) LinkAsset(ctx context.Context, groupID uuid.UUID, asset Asset) (err error)
- func (m *Manager) List(kind Flags) (gs []Group)
- func (m *Manager) Logger() *zap.Logger
- func (m *Manager) Lookup(ctx context.Context, groupID uuid.UUID) (g Group, err error)
- func (m *Manager) Parent(ctx context.Context, g Group) (p Group, err error)
- func (m *Manager) Put(ctx context.Context, g Group) error
- func (m *Manager) Remove(ctx context.Context, groupID uuid.UUID) error
- func (m *Manager) SetLogger(logger *zap.Logger) error
- func (m *Manager) SetParent(ctx context.Context, groupID, newParentID uuid.UUID) (err error)
- func (m *Manager) Store() (Store, error)
- func (m *Manager) UnlinkAsset(ctx context.Context, groupID uuid.UUID, asset Asset) (err error)
- func (m *Manager) Validate(ctx context.Context, groupID uuid.UUID) (err error)
- type PostgreSQLStore
- func (s *PostgreSQLStore) CreateRelation(ctx context.Context, rel Relation) (err error)
- func (s *PostgreSQLStore) DeleteByID(ctx context.Context, groupID uuid.UUID) (err error)
- func (s *PostgreSQLStore) DeleteRelation(ctx context.Context, rel Relation) (err error)
- func (s *PostgreSQLStore) FetchAllGroups(ctx context.Context) (gs []Group, err error)
- func (s *PostgreSQLStore) FetchAllRelations(ctx context.Context) (relations []Relation, err error)
- func (s *PostgreSQLStore) FetchGroupByID(ctx context.Context, groupID uuid.UUID) (Group, error)
- func (s *PostgreSQLStore) FetchGroupByKey(ctx context.Context, key string) (Group, error)
- func (s *PostgreSQLStore) FetchGroupByName(ctx context.Context, name string) (g Group, err error)
- func (s *PostgreSQLStore) FetchGroupRelations(ctx context.Context, groupID uuid.UUID) ([]Relation, error)
- func (s *PostgreSQLStore) FetchGroupsByName(ctx context.Context, isPartial bool, name string) (gs []Group, err error)
- func (s *PostgreSQLStore) HasRelation(ctx context.Context, rel Relation) (bool, error)
- func (s *PostgreSQLStore) UpsertGroup(ctx context.Context, g Group) (Group, error)
- type Relation
- type Store
- type Team
Constants ¶
This section is empty.
Variables ¶
var ( ErrNilDatabase = errors.New("data is nil") ErrNoParent = errors.New("no parent group") ErrNilGroupID = errors.New("role group id is zero") ErrZeroRoleID = errors.New("role id is zero") ErrZeroID = errors.New("id is zero") ErrNonZeroID = errors.New("id is not zero") ErrNilAssetID = errors.New("asset id is zero") ErrInvalidAssetKind = errors.New("asset kind is invalid") ErrNilStore = errors.New("group store is nil") ErrRelationNotFound = errors.New("relation not found") ErrGroupAlreadyRegistered = errors.New("group is already registered") ErrEmptyKey = errors.New("empty group key") ErrEmptyGroupName = errors.New("empty group name") ErrDuplicateGroup = errors.New("duplicate group") ErrDuplicateParent = errors.New("duplicate parent") ErrDuplicateRelation = errors.New("duplicate relation") ErrAssetNotEligible = errors.New("asset is not eligible for this operation") ErrGroupKindMismatch = errors.New("group kinds mismatch") ErrInvalidKind = errors.New("invalid group kind") ErrNotAsset = errors.New("asset is not a asset") ErrAlreadyAsset = errors.New("already a asset") ErrCircuitedParent = errors.New("circuited parenting") ErrCircuitCheckTimeout = errors.New("circuit check timed out") ErrNilManager = errors.New("group manager is nil") ErrGroupNotFound = errors.New("group not found") ErrGroupKeyTaken = errors.New("group key is already taken") ErrUnknownKind = errors.New("unknown group kind") ErrInvalidGroupKey = errors.New("invalid group key") ErrInvalidGroupName = errors.New("invalid group name") ErrEmptyGroupKey = errors.New("group key is empty") ErrAmbiguousKind = errors.New("group kind is ambiguous") )
errors
Functions ¶
func FlagDictionary ¶
FlagDictionary returns a map of property flag values to their respective names
Types ¶
type CassandraStore ¶
type CassandraStore struct {
// contains filtered or unexported fields
}
func (CassandraStore) CreateRelation ¶
func (c CassandraStore) CreateRelation(ctx context.Context, rel Relation) error
func (CassandraStore) DeleteByID ¶
func (CassandraStore) DeleteRelation ¶
func (c CassandraStore) DeleteRelation(ctx context.Context, rel Relation) error
func (CassandraStore) FetchAllGroups ¶
func (c CassandraStore) FetchAllGroups(ctx context.Context) (gs []Group, err error)
func (CassandraStore) FetchAllRelations ¶
func (c CassandraStore) FetchAllRelations(ctx context.Context) ([]Relation, error)
func (CassandraStore) FetchGroupByID ¶
func (CassandraStore) FetchGroupByKey ¶
func (CassandraStore) FetchGroupByName ¶
func (CassandraStore) FetchGroupRelations ¶
func (CassandraStore) FetchGroupsByName ¶
func (CassandraStore) HasRelation ¶
func (CassandraStore) UpsertGroup ¶
type Flags ¶
type Flags uint8
Flags designates whether a group is enabled, default, a role or a standard group
type Group ¶
type Group struct { DisplayName string `db:"name" json:"name"` Key string `db:"key" json:"key" valid:"required,ascii"` ID uuid.UUID `db:"id" json:"id"` ParentID uuid.UUID `db:"parent_id" json:"parent_id"` Flags Flags `db:"kind" json:"kind"` // contains filtered or unexported fields }
Group represents a asset group TODO: replace Flags and IsDefault with a Flags bitmask TODO: work out a simple Flags bit layout
type Manager ¶
Manager is a group manager TODO: add default groups which need not to be assigned explicitly
func NewManager ¶
NewManager initializing a new group manager
func (*Manager) Create ¶
func (m *Manager) Create(ctx context.Context, flags Flags, parentID uuid.UUID, key string, name string) (g Group, err error)
Upsert creates new group
func (*Manager) CreateRelation ¶
CreateRelation adding asset to a group NOTE: storing relation only if group has a store set is implicit and should at least log/print about the occurrence
func (*Manager) DeleteGroup ¶
DeletePolicy returns an accesspolicy policy by its ObjectID NOTE: also deletes all relations and nested groups (should asset have sufficient accesspolicy rights to do that) TODO: implement recursive deletion
func (*Manager) DeleteRelation ¶
DeleteRelation removes asset from a group
func (*Manager) GroupByKey ¶
PolicyByKey returns a group by name
func (*Manager) GroupByName ¶
GroupByName returns an accesspolicy policy by its key TODO: add expirable caching
func (*Manager) GroupsByAssetID ¶
GroupsByAssetID returns a slice of groups to which a given asset belongs
func (*Manager) Invite ¶
Invite an existing user to become a asset of the group NOTE: this is optional and often can be disabled for better control TODO: requires careful planning
func (*Manager) IsCircuited ¶
IsCircuited tests whether the parents trace back to a nil
func (*Manager) LinkAsset ¶
LinkAsset adds a asset to the group assets NOTE: does not affect the store
func (*Manager) Logger ¶
Logger returns primary logger if is set, otherwise initializing and returning
func (*Manager) UnlinkAsset ¶
UnlinkAsset removes a asset from the group assets NOTE: does not affect the store
type PostgreSQLStore ¶
type PostgreSQLStore struct {
// contains filtered or unexported fields
}
func (*PostgreSQLStore) CreateRelation ¶
func (s *PostgreSQLStore) CreateRelation(ctx context.Context, rel Relation) (err error)
func (*PostgreSQLStore) DeleteByID ¶
func (*PostgreSQLStore) DeleteRelation ¶
func (s *PostgreSQLStore) DeleteRelation(ctx context.Context, rel Relation) (err error)
func (*PostgreSQLStore) FetchAllGroups ¶
func (s *PostgreSQLStore) FetchAllGroups(ctx context.Context) (gs []Group, err error)
func (*PostgreSQLStore) FetchAllRelations ¶
func (s *PostgreSQLStore) FetchAllRelations(ctx context.Context) (relations []Relation, err error)
func (*PostgreSQLStore) FetchGroupByID ¶
func (*PostgreSQLStore) FetchGroupByKey ¶
func (*PostgreSQLStore) FetchGroupByName ¶
func (*PostgreSQLStore) FetchGroupRelations ¶
func (*PostgreSQLStore) FetchGroupsByName ¶
func (*PostgreSQLStore) HasRelation ¶
func (*PostgreSQLStore) UpsertGroup ¶
type Store ¶
type Store interface { UpsertGroup(ctx context.Context, g Group) (Group, error) CreateRelation(ctx context.Context, rel Relation) error FetchGroupByID(ctx context.Context, groupID uuid.UUID) (g Group, err error) FetchGroupByKey(ctx context.Context, key string) (g Group, err error) FetchGroupByName(ctx context.Context, name string) (g Group, err error) FetchGroupsByName(ctx context.Context, isPartial bool, name string) (gs []Group, err error) HasRelation(ctx context.Context, rel Relation) (bool, error) FetchAllGroups(ctx context.Context) (gs []Group, err error) FetchAllRelations(ctx context.Context) ([]Relation, error) FetchGroupRelations(ctx context.Context, groupID uuid.UUID) ([]Relation, error) DeleteByID(ctx context.Context, groupID uuid.UUID) error DeleteRelation(ctx context.Context, rel Relation) error }
Store describes a storage contract for groups specifically