service

package
v0.0.0-...-6cdb919 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2024 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertPostMemberToMember

func ConvertPostMemberToMember(postMember PostMember, currentUser userauth.User) (*models.Member, error)

func ConvertResourceType

func ConvertResourceType(resourceTypeStr string) (models.ResourceType, bool)

func DeduplicateMember

func DeduplicateMember(members []models.Member) []models.Member

Types

type Member

type Member struct {
	// ID the uniq id of the member entry
	ID uint

	// MemberInfo username or groupID
	MemberInfo string

	// MemberName
	MemberName string

	// MemberPath the path of the member
	MemberPath string

	// MemberType user or group
	MemberType models.MemberType

	// SourceInfo direct or from application/group
	SourceInfo string

	// Role the role name that bind
	Role string

	// GrantedBy user who grant the role
	GrantedBy string

	// GrantTime
	GrantTime time.Time
}

type PostMember

type PostMember struct {
	// ResourceType group/application/cluster
	ResourceType string

	// ResourceID group id;application id ...
	ResourceID uint

	// MemberInfo group id / username
	MemberInfo uint

	// MemberType user or group
	MemberType models.MemberType

	// Role owner/maintainer/develop/...
	Role string
}

type Service

type Service interface {
	// CreateMember post a new member
	CreateMember(ctx context.Context, postMember PostMember) (*models.Member, error)
	// GetMember return the current user member of direct or parent
	GetMember(ctx context.Context, memberID uint) (*models.Member, error)
	// UpdateMember update the member by the memberID
	UpdateMember(ctx context.Context, memberID uint, role string) (*models.Member, error)
	// RemoveMember Remove the member by the memberID
	RemoveMember(ctx context.Context, memberID uint) error
	// ListMember list all the member of the resource
	ListMember(ctx context.Context, resourceType string, resourceID uint) ([]models.Member, error)
	// GetMemberOfResource return the current user's role of the resource (member from direct or parent)
	GetMemberOfResource(ctx context.Context, resourceType string, resourceID string) (*models.Member, error)
	// RequirePermissionEqualOrHigher helps to check if your permission is higher than specified member
	RequirePermissionEqualOrHigher(ctx context.Context, role, resourceType string, resourceID uint) error
}

nolint

func NewService

func NewService(roleService roleservice.Service, oauthManager oauthmanager.Manager,
	manager *managerparam.Manager) Service

Jump to

Keyboard shortcuts

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