roles

package
v0.0.0-...-4ee07f5 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OpAddRole svcutil.Operation = iota
	OpRemoveRole
	OpUpdateRoleName
	OpRetrieveRole
	OpRetrieveAllRoles
	OpRoleAddActions
	OpRoleListActions
	OpRoleCheckActionsExists
	OpRoleRemoveActions
	OpRoleRemoveAllActions
	OpRoleAddMembers
	OpRoleListMembers
	OpRoleCheckMembersExists
	OpRoleRemoveMembers
	OpRoleRemoveAllMembers
)

Variables

This section is empty.

Functions

func NewOperationPerm

func NewOperationPerm() svcutil.OperationPerm

Types

type Action

type Action string

func (Action) String

func (ac Action) String() string

type BuiltInRoleName

type BuiltInRoleName RoleName

func (BuiltInRoleName) String

func (b BuiltInRoleName) String() string

func (BuiltInRoleName) ToRoleName

func (b BuiltInRoleName) ToRoleName() RoleName

type EntityActionRole

type EntityActionRole struct {
	EntityID string `json:"entity_id"`
	Action   string `json:"action"`
	RoleID   string `json:"role_id"`
}

type EntityMemberRole

type EntityMemberRole struct {
	EntityID string `json:"entity_id"`
	MemberID string `json:"member_id"`
	RoleID   string `json:"role_id"`
}

type Member

type Member string

func (Member) String

func (mem Member) String() string

type MembersPage

type MembersPage struct {
	Total   uint64   `json:"total"`
	Offset  uint64   `json:"offset"`
	Limit   uint64   `json:"limit"`
	Members []string `json:"members"`
}

type ProvisionManageService

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

func NewProvisionManageService

func NewProvisionManageService(entityType string, repo Repository, policy policies.Service, sidProvider magistrala.IDProvider, actions []Action, builtInRoles map[BuiltInRoleName][]Action) (ProvisionManageService, error)

func (ProvisionManageService) AddNewEntitiesRoles

func (r ProvisionManageService) AddNewEntitiesRoles(ctx context.Context, domainID, userID string, entityIDs []string, optionalEntityPolicies []policies.Policy, newBuiltInRoleMembers map[BuiltInRoleName][]Member) (retRolesProvision []RoleProvision, retErr error)

func (ProvisionManageService) AddRole

func (r ProvisionManageService) AddRole(ctx context.Context, session authn.Session, entityID string, roleName string, optionalActions []string, optionalMembers []string) (retRole Role, retErr error)

func (ProvisionManageService) ListAvailableActions

func (r ProvisionManageService) ListAvailableActions(ctx context.Context, session authn.Session) ([]string, error)

func (ProvisionManageService) RemoveEntitiesRoles

func (r ProvisionManageService) RemoveEntitiesRoles(ctx context.Context, domainID, userID string, entityIDs []string, optionalFilterDeletePolicies []policies.Policy, optionalDeletePolicies []policies.Policy) error

func (ProvisionManageService) RemoveMemberFromAllRoles

func (r ProvisionManageService) RemoveMemberFromAllRoles(ctx context.Context, session authn.Session, member string) (err error)

func (ProvisionManageService) RemoveRole

func (r ProvisionManageService) RemoveRole(ctx context.Context, session authn.Session, entityID, roleName string) error

func (ProvisionManageService) RetrieveAllRoles

func (r ProvisionManageService) RetrieveAllRoles(ctx context.Context, session authn.Session, entityID string, limit, offset uint64) (RolePage, error)

func (ProvisionManageService) RetrieveRole

func (r ProvisionManageService) RetrieveRole(ctx context.Context, session authn.Session, entityID, roleName string) (Role, error)

func (ProvisionManageService) RoleAddActions

func (r ProvisionManageService) RoleAddActions(ctx context.Context, session authn.Session, entityID, roleName string, actions []string) (retActs []string, retErr error)

func (ProvisionManageService) RoleAddMembers

func (r ProvisionManageService) RoleAddMembers(ctx context.Context, session authn.Session, entityID, roleName string, members []string) (retMems []string, retErr error)

func (ProvisionManageService) RoleCheckActionsExists

func (r ProvisionManageService) RoleCheckActionsExists(ctx context.Context, session authn.Session, entityID, roleName string, actions []string) (bool, error)

func (ProvisionManageService) RoleCheckMembersExists

func (r ProvisionManageService) RoleCheckMembersExists(ctx context.Context, session authn.Session, entityID, roleName string, members []string) (bool, error)

func (ProvisionManageService) RoleListActions

func (r ProvisionManageService) RoleListActions(ctx context.Context, session authn.Session, entityID, roleName string) ([]string, error)

func (ProvisionManageService) RoleListMembers

func (r ProvisionManageService) RoleListMembers(ctx context.Context, session authn.Session, entityID, roleName string, limit, offset uint64) (MembersPage, error)

func (ProvisionManageService) RoleRemoveActions

func (r ProvisionManageService) RoleRemoveActions(ctx context.Context, session authn.Session, entityID, roleName string, actions []string) (err error)

func (ProvisionManageService) RoleRemoveAllActions

func (r ProvisionManageService) RoleRemoveAllActions(ctx context.Context, session authn.Session, entityID, roleName string) error

func (ProvisionManageService) RoleRemoveAllMembers

func (r ProvisionManageService) RoleRemoveAllMembers(ctx context.Context, session authn.Session, entityID, roleName string) (err error)

func (ProvisionManageService) RoleRemoveMembers

func (r ProvisionManageService) RoleRemoveMembers(ctx context.Context, session authn.Session, entityID, roleName string, members []string) (err error)

func (ProvisionManageService) UpdateRoleName

func (r ProvisionManageService) UpdateRoleName(ctx context.Context, session authn.Session, entityID, oldRoleName, newRoleName string) (Role, error)

type Provisioner

type Provisioner interface {
	AddNewEntitiesRoles(ctx context.Context, domainID, userID string, entityIDs []string, optionalEntityPolicies []policies.Policy, newBuiltInRoleMembers map[BuiltInRoleName][]Member) ([]RoleProvision, error)
	RemoveEntitiesRoles(ctx context.Context, domainID, userID string, entityIDs []string, optionalFilterDeletePolicies []policies.Policy, optionalDeletePolicies []policies.Policy) error
}

type Repository

type Repository interface {
	AddRoles(ctx context.Context, rps []RoleProvision) ([]Role, error)
	RemoveRoles(ctx context.Context, roleIDs []string) error
	UpdateRole(ctx context.Context, ro Role) (Role, error)
	RetrieveRole(ctx context.Context, roleID string) (Role, error)
	RetrieveRoleByEntityIDAndName(ctx context.Context, entityID, roleName string) (Role, error)
	RetrieveAllRoles(ctx context.Context, entityID string, limit, offset uint64) (RolePage, error)
	RoleAddActions(ctx context.Context, role Role, actions []string) (ops []string, err error)
	RoleListActions(ctx context.Context, roleID string) ([]string, error)
	RoleCheckActionsExists(ctx context.Context, roleID string, actions []string) (bool, error)
	RoleRemoveActions(ctx context.Context, role Role, actions []string) (err error)
	RoleRemoveAllActions(ctx context.Context, role Role) error
	RoleAddMembers(ctx context.Context, role Role, members []string) ([]string, error)
	RoleListMembers(ctx context.Context, roleID string, limit, offset uint64) (MembersPage, error)
	RoleCheckMembersExists(ctx context.Context, roleID string, members []string) (bool, error)
	RoleRemoveMembers(ctx context.Context, role Role, members []string) (err error)
	RoleRemoveAllMembers(ctx context.Context, role Role) (err error)
	RetrieveEntitiesRolesActionsMembers(ctx context.Context, entityIDs []string) ([]EntityActionRole, []EntityMemberRole, error)
	RemoveMemberFromAllRoles(ctx context.Context, members string) (err error)
}

type Role

type Role struct {
	ID        string    `json:"id"`
	Name      string    `json:"name"`
	EntityID  string    `json:"entity_id"`
	CreatedBy string    `json:"created_by"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedBy string    `json:"updated_by"`
	UpdatedAt time.Time `json:"updated_at"`
}

type RoleManager

type RoleManager interface {
	// Add New role to entity
	AddRole(ctx context.Context, session authn.Session, entityID, roleName string, optionalActions []string, optionalMembers []string) (Role, error)

	// Remove removes the roles of entity.
	RemoveRole(ctx context.Context, session authn.Session, entityID, roleName string) error

	// UpdateName update the name of the entity role.
	UpdateRoleName(ctx context.Context, session authn.Session, entityID, oldRoleName, newRoleName string) (Role, error)

	RetrieveRole(ctx context.Context, session authn.Session, entityID, roleName string) (Role, error)

	RetrieveAllRoles(ctx context.Context, session authn.Session, entityID string, limit, offset uint64) (RolePage, error)

	ListAvailableActions(ctx context.Context, session authn.Session) ([]string, error)

	RoleAddActions(ctx context.Context, session authn.Session, entityID, roleName string, actions []string) (ops []string, err error)

	RoleListActions(ctx context.Context, session authn.Session, entityID, roleName string) ([]string, error)

	RoleCheckActionsExists(ctx context.Context, session authn.Session, entityID, roleName string, actions []string) (bool, error)

	RoleRemoveActions(ctx context.Context, session authn.Session, entityID, roleName string, actions []string) (err error)

	RoleRemoveAllActions(ctx context.Context, session authn.Session, entityID, roleName string) error

	RoleAddMembers(ctx context.Context, session authn.Session, entityID, roleName string, members []string) ([]string, error)

	RoleListMembers(ctx context.Context, session authn.Session, entityID, roleName string, limit, offset uint64) (MembersPage, error)

	RoleCheckMembersExists(ctx context.Context, session authn.Session, entityID, roleName string, members []string) (bool, error)

	RoleRemoveMembers(ctx context.Context, session authn.Session, entityID, roleName string, members []string) (err error)

	RoleRemoveAllMembers(ctx context.Context, session authn.Session, entityID, roleName string) (err error)

	RemoveMemberFromAllRoles(ctx context.Context, session authn.Session, memberID string) (err error)
}

type RoleName

type RoleName string

func (RoleName) String

func (r RoleName) String() string

type RolePage

type RolePage struct {
	Total  uint64 `json:"total"`
	Offset uint64 `json:"offset"`
	Limit  uint64 `json:"limit"`
	Roles  []Role `json:"roles"`
}

type RoleProvision

type RoleProvision struct {
	Role
	OptionalActions []string `json:"-"`
	OptionalMembers []string `json:"-"`
}

type Roles

type Roles interface {
	// Add New role to entity
	AddRole(ctx context.Context, session authn.Session, entityID, roleName string, optionalActions []string, optionalMembers []string) (Role, error)

	// Remove removes the roles of entity.
	RemoveRole(ctx context.Context, session authn.Session, entityID, roleName string) error

	// UpdateName update the name of the entity role.
	UpdateRoleName(ctx context.Context, session authn.Session, entityID, oldRoleName, newRoleName string) (Role, error)

	RetrieveRole(ctx context.Context, session authn.Session, entityID, roleName string) (Role, error)

	RetrieveAllRoles(ctx context.Context, session authn.Session, entityID string, limit, offset uint64) (RolePage, error)

	ListAvailableActions(ctx context.Context, session authn.Session) ([]string, error)

	RoleAddActions(ctx context.Context, session authn.Session, entityID, roleName string, actions []string) (ops []string, err error)

	RoleListActions(ctx context.Context, session authn.Session, entityID, roleName string) ([]string, error)

	RoleCheckActionsExists(ctx context.Context, session authn.Session, entityID, roleName string, actions []string) (bool, error)

	RoleRemoveActions(ctx context.Context, session authn.Session, entityID, roleName string, actions []string) (err error)

	RoleRemoveAllActions(ctx context.Context, session authn.Session, entityID, roleName string) error

	RoleAddMembers(ctx context.Context, session authn.Session, entityID, roleName string, members []string) ([]string, error)

	RoleListMembers(ctx context.Context, session authn.Session, entityID, roleName string, limit, offset uint64) (MembersPage, error)

	RoleCheckMembersExists(ctx context.Context, session authn.Session, entityID, roleName string, members []string) (bool, error)

	RoleRemoveMembers(ctx context.Context, session authn.Session, entityID, roleName string, members []string) (err error)

	RoleRemoveAllMembers(ctx context.Context, session authn.Session, entityID, roleName string) (err error)

	RemoveMembersFromAllRoles(ctx context.Context, session authn.Session, members []string) (err error)

	RemoveMembersFromRoles(ctx context.Context, session authn.Session, members []string, roleNames []string) (err error)

	RemoveActionsFromAllRoles(ctx context.Context, session authn.Session, actions []string) (err error)

	RemoveActionsFromRoles(ctx context.Context, session authn.Session, actions []string, roleNames []string) (err error)
}

Directories

Path Synopsis
api
events
Package events provides the domain concept definitions needed to support Magistrala auth service functionality.
Package events provides the domain concept definitions needed to support Magistrala auth service functionality.

Jump to

Keyboard shortcuts

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