group_service

package
v0.0.20 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SUPER_USER_ID = uuid.MustParse("60303901-c88f-47f0-b888-ecf92988d9fc")

Skips permission checks

Functions

This section is empty.

Types

type GroupCreateInput

type GroupCreateInput struct {
	Name        string `required:"true"`
	Description string `required:"true"`
}

Input for creating group

type GroupService

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

Integrate group management with internal permissions and kubernetes RBAC

func NewGroupService

func NewGroupService(repo repositories.RepositoriesInterface, rbacManager *k8s.RBACManager) *GroupService

func (*GroupService) AddUserToGroup

func (self *GroupService) AddUserToGroup(ctx context.Context, requesterUserID, targetUserID, groupID uuid.UUID) error

func (*GroupService) CreateGroup

func (self *GroupService) CreateGroup(ctx context.Context, userID uuid.UUID, input *GroupCreateInput) (*ent.Group, error)

func (*GroupService) DeleteGroup

func (self *GroupService) DeleteGroup(ctx context.Context, userID uuid.UUID, groupID uuid.UUID) error

DeleteGroup deletes a group if the user has permissions

func (*GroupService) GetGroupByID

func (self *GroupService) GetGroupByID(ctx context.Context, userID uuid.UUID, groupID uuid.UUID) (*ent.Group, error)

GetGroupByID retrieves a group by its ID

func (*GroupService) GetGroupMembers

func (self *GroupService) GetGroupMembers(ctx context.Context, requesterUserID, groupID uuid.UUID) ([]*ent.User, error)

GetGroupMembers lists all users who are members of a group

func (*GroupService) GetGroupPermissions

func (self *GroupService) GetGroupPermissions(
	ctx context.Context,
	requesterUserID uuid.UUID,
	groupID uuid.UUID,
) ([]*ent.Permission, error)

GetGroupPermissions lists all permissions for a group

func (*GroupService) GetUserGroups

func (self *GroupService) GetUserGroups(
	ctx context.Context,
	requesterUserID uuid.UUID,
	targetUserID uuid.UUID,
) ([]*ent.Group, error)

GetUserGroups gets all groups a user belongs to

func (*GroupService) GrantPermissionToGroup

func (self *GroupService) GrantPermissionToGroup(
	ctx context.Context,
	requesterUserID,
	groupID uuid.UUID,
	permAction schema.PermittedAction,
	resourceType schema.ResourceType,
	selector schema.ResourceSelector,
) (*ent.Permission, error)

GrantPermissionToGroup grants a permission to a group

func (*GroupService) ListGroups

func (self *GroupService) ListGroups(ctx context.Context, userID uuid.UUID) ([]*ent.Group, error)

ListGroups retrieves all groups the user has permission to view

func (*GroupService) RemoveUserFromGroup

func (self *GroupService) RemoveUserFromGroup(ctx context.Context, requesterUserID, targetUserID, groupID uuid.UUID) error

RemoveUserFromGroup removes a user from a group if the requester has permission

func (*GroupService) RevokePermissionFromGroup

func (self *GroupService) RevokePermissionFromGroup(
	ctx context.Context,
	requesterUserID uuid.UUID,
	groupID uuid.UUID,
	permissionID uuid.UUID,
) error

RevokePermissionFromGroup revokes a permission from a group

func (*GroupService) UpdateGroup

func (self *GroupService) UpdateGroup(ctx context.Context, userID uuid.UUID, groupID uuid.UUID, input GroupCreateInput) (*ent.Group, error)

UpdateGroup updates a group if the user has permission

Jump to

Keyboard shortcuts

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