rolesgroups

package
v0.0.0-...-5ab21f3 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DependencySet = wire.NewSet(
	wire.Struct(new(Store), "*"),
	wire.Struct(new(Queries), "*"),
	wire.Struct(new(Commands), "*"),
)
View Source
var ErrGroupDuplicateKey = apierrors.BadRequest.WithReason("GroupDuplicateKey").New("duplicate group key")
View Source
var ErrGroupNotFound = apierrors.NotFound.WithReason("GroupNotFound").New("group not found")
View Source
var ErrRoleDuplicateKey = apierrors.BadRequest.WithReason("RoleDuplicateKey").New("duplicate role key")
View Source
var ErrRoleNotFound = apierrors.NotFound.WithReason("RoleNotFound").New("role not found")
View Source
var GroupUnknownKeys = apierrors.NotFound.WithReason("GroupUnknownKeys")
View Source
var KeySchema = validation.NewSimpleSchema(`
	{
		"type": "string",
		"minLength": 1,
		"maxLength": 40,
		"pattern": "^[a-zA-Z_][a-zA-Z0-9:_]*$",
		"format": "x_role_group_key"
	}
`)
View Source
var RoleUnknownKeys = apierrors.NotFound.WithReason("RoleUnknownKeys")
View Source
var UserUnknownKeys = apierrors.NotFound.WithReason("UserUnknownKeys")

Functions

func ValidateKey

func ValidateKey(key string) error

Types

type AddGroupToRolesOptions

type AddGroupToRolesOptions struct {
	GroupKey string
	RoleKeys []string
}

type AddGroupToUsersOptions

type AddGroupToUsersOptions struct {
	GroupKey string
	UserIDs  []string
}

type AddRoleToGroupsOptions

type AddRoleToGroupsOptions struct {
	RoleKey   string
	GroupKeys []string
}

type AddRoleToUsersOptions

type AddRoleToUsersOptions struct {
	RoleKey string
	UserIDs []string
}

type AddUserToGroupsOptions

type AddUserToGroupsOptions struct {
	UserID    string
	GroupKeys []string
}

type AddUserToRolesOptions

type AddUserToRolesOptions struct {
	UserID   string
	RoleKeys []string
}

type Commands

type Commands struct {
	Store *Store
}

func (*Commands) AddGroupToRoles

func (c *Commands) AddGroupToRoles(ctx context.Context, options *AddGroupToRolesOptions) (*model.Group, error)

func (*Commands) AddGroupToUsers

func (c *Commands) AddGroupToUsers(ctx context.Context, options *AddGroupToUsersOptions) (*model.Group, error)

func (*Commands) AddRoleToGroups

func (c *Commands) AddRoleToGroups(ctx context.Context, options *AddRoleToGroupsOptions) (*model.Role, error)

func (*Commands) AddRoleToUsers

func (c *Commands) AddRoleToUsers(ctx context.Context, options *AddRoleToUsersOptions) (*model.Role, error)

func (*Commands) AddUserToGroups

func (c *Commands) AddUserToGroups(ctx context.Context, options *AddUserToGroupsOptions) error

func (*Commands) AddUserToRoles

func (c *Commands) AddUserToRoles(ctx context.Context, options *AddUserToRolesOptions) error

func (*Commands) CreateGroup

func (c *Commands) CreateGroup(ctx context.Context, options *NewGroupOptions) (*model.Group, error)

func (*Commands) CreateRole

func (c *Commands) CreateRole(ctx context.Context, options *NewRoleOptions) (*model.Role, error)

func (*Commands) DeleteGroup

func (c *Commands) DeleteGroup(ctx context.Context, id string) error

func (*Commands) DeleteRole

func (c *Commands) DeleteRole(ctx context.Context, id string) error

func (*Commands) DeleteUserGroup

func (c *Commands) DeleteUserGroup(ctx context.Context, userID string) error

func (*Commands) DeleteUserRole

func (c *Commands) DeleteUserRole(ctx context.Context, userID string) error

func (*Commands) RemoveGroupFromRoles

func (c *Commands) RemoveGroupFromRoles(ctx context.Context, options *RemoveGroupFromRolesOptions) (*model.Group, error)

func (*Commands) RemoveGroupFromUsers

func (c *Commands) RemoveGroupFromUsers(ctx context.Context, options *RemoveGroupFromUsersOptions) (*model.Group, error)

func (*Commands) RemoveRoleFromGroups

func (c *Commands) RemoveRoleFromGroups(ctx context.Context, options *RemoveRoleFromGroupsOptions) (*model.Role, error)

func (*Commands) RemoveRoleFromUsers

func (c *Commands) RemoveRoleFromUsers(ctx context.Context, options *RemoveRoleFromUsersOptions) (*model.Role, error)

func (*Commands) RemoveUserFromGroups

func (c *Commands) RemoveUserFromGroups(ctx context.Context, options *RemoveUserFromGroupsOptions) error

func (*Commands) RemoveUserFromRoles

func (c *Commands) RemoveUserFromRoles(ctx context.Context, options *RemoveUserFromRolesOptions) error

func (*Commands) ResetUserGroup

func (c *Commands) ResetUserGroup(ctx context.Context, options *ResetUserGroupOptions) error

func (*Commands) ResetUserRole

func (c *Commands) ResetUserRole(ctx context.Context, options *ResetUserRoleOptions) error

func (*Commands) UpdateGroup

func (c *Commands) UpdateGroup(ctx context.Context, options *UpdateGroupOptions) (*model.Group, error)

func (*Commands) UpdateRole

func (c *Commands) UpdateRole(ctx context.Context, options *UpdateRoleOptions) (*model.Role, error)

type Group

type Group struct {
	ID          string
	CreatedAt   time.Time
	UpdatedAt   time.Time
	Key         string
	Name        *string
	Description *string
}

func (*Group) ToModel

func (r *Group) ToModel() *model.Group

type ListGroupsOptions

type ListGroupsOptions struct {
	SearchKeyword string
	ExcludedIDs   []string
}

type ListRolesOptions

type ListRolesOptions struct {
	SearchKeyword string
	ExcludedIDs   []string
}

type NewGroupOptions

type NewGroupOptions struct {
	Key         string
	Name        *string
	Description *string
}

type NewRoleOptions

type NewRoleOptions struct {
	Key         string
	Name        *string
	Description *string
}

type Queries

type Queries struct {
	Store *Store
}

func (*Queries) CountGroups

func (q *Queries) CountGroups(ctx context.Context) (uint64, error)

func (*Queries) CountRoles

func (q *Queries) CountRoles(ctx context.Context) (uint64, error)

func (*Queries) GetGroup

func (q *Queries) GetGroup(ctx context.Context, id string) (*model.Group, error)

func (*Queries) GetManyGroups

func (q *Queries) GetManyGroups(ctx context.Context, ids []string) ([]*model.Group, error)

func (*Queries) GetManyRoles

func (q *Queries) GetManyRoles(ctx context.Context, ids []string) ([]*model.Role, error)

func (*Queries) GetRole

func (q *Queries) GetRole(ctx context.Context, id string) (*model.Role, error)

func (*Queries) ListAllGroupsByKeys

func (f *Queries) ListAllGroupsByKeys(ctx context.Context, keys []string) ([]*model.Group, error)

func (*Queries) ListAllRolesByKeys

func (f *Queries) ListAllRolesByKeys(ctx context.Context, keys []string) ([]*model.Role, error)

func (*Queries) ListAllUserIDsByEffectiveRoleIDs

func (q *Queries) ListAllUserIDsByEffectiveRoleIDs(ctx context.Context, roleIDs []string) ([]string, error)

func (*Queries) ListAllUserIDsByGroupIDs

func (q *Queries) ListAllUserIDsByGroupIDs(ctx context.Context, groupIDs []string) ([]string, error)

func (*Queries) ListAllUserIDsByGroupKeys

func (q *Queries) ListAllUserIDsByGroupKeys(ctx context.Context, groupKeys []string) ([]string, error)

func (*Queries) ListAllUserIDsByRoleIDs

func (q *Queries) ListAllUserIDsByRoleIDs(ctx context.Context, roleIDs []string) ([]string, error)

func (*Queries) ListEffectiveRolesByUserID

func (q *Queries) ListEffectiveRolesByUserID(ctx context.Context, userID string) ([]*model.Role, error)

func (*Queries) ListGroups

func (q *Queries) ListGroups(ctx context.Context, options *ListGroupsOptions, pageArgs graphqlutil.PageArgs) ([]model.PageItemRef, error)

func (*Queries) ListGroupsByRoleID

func (q *Queries) ListGroupsByRoleID(ctx context.Context, roleID string) ([]*model.Group, error)

func (*Queries) ListGroupsByUserID

func (q *Queries) ListGroupsByUserID(ctx context.Context, userID string) ([]*model.Group, error)

func (*Queries) ListGroupsByUserIDs

func (q *Queries) ListGroupsByUserIDs(ctx context.Context, userIDs []string) (map[string][]*model.Group, error)

func (*Queries) ListRoles

func (q *Queries) ListRoles(ctx context.Context, options *ListRolesOptions, pageArgs graphqlutil.PageArgs) ([]model.PageItemRef, error)

func (*Queries) ListRolesByGroupID

func (q *Queries) ListRolesByGroupID(ctx context.Context, groupID string) ([]*model.Role, error)

func (*Queries) ListRolesByUserID

func (q *Queries) ListRolesByUserID(ctx context.Context, userID string) ([]*model.Role, error)

func (*Queries) ListRolesByUserIDs

func (q *Queries) ListRolesByUserIDs(ctx context.Context, userIDs []string) (map[string][]*model.Role, error)

func (*Queries) ListUserIDsByGroupID

func (q *Queries) ListUserIDsByGroupID(ctx context.Context, groupID string, pageArgs graphqlutil.PageArgs) ([]model.PageItemRef, error)

func (*Queries) ListUserIDsByRoleID

func (q *Queries) ListUserIDsByRoleID(ctx context.Context, roleID string, pageArgs graphqlutil.PageArgs) ([]model.PageItemRef, error)

type RemoveGroupFromRolesOptions

type RemoveGroupFromRolesOptions struct {
	GroupKey string
	RoleKeys []string
}

type RemoveGroupFromUsersOptions

type RemoveGroupFromUsersOptions struct {
	GroupKey string
	UserIDs  []string
}

type RemoveRoleFromGroupsOptions

type RemoveRoleFromGroupsOptions struct {
	RoleKey   string
	GroupKeys []string
}

type RemoveRoleFromUsersOptions

type RemoveRoleFromUsersOptions struct {
	RoleKey string
	UserIDs []string
}

type RemoveUserFromGroupsOptions

type RemoveUserFromGroupsOptions struct {
	UserID    string
	GroupKeys []string
}

type RemoveUserFromRolesOptions

type RemoveUserFromRolesOptions struct {
	UserID   string
	RoleKeys []string
}

type ResetUserGroupOptions

type ResetUserGroupOptions struct {
	UserID    string
	GroupKeys []string
}

type ResetUserRoleOptions

type ResetUserRoleOptions struct {
	UserID   string
	RoleKeys []string
}

type Role

type Role struct {
	ID          string
	CreatedAt   time.Time
	UpdatedAt   time.Time
	Key         string
	Name        *string
	Description *string
}

func (*Role) ToModel

func (r *Role) ToModel() *model.Role

type Store

type Store struct {
	SQLBuilder  *appdb.SQLBuilderApp
	SQLExecutor *appdb.SQLExecutor
	Clock       clock.Clock
}

func (*Store) AddGroupToRoles

func (s *Store) AddGroupToRoles(ctx context.Context, options *AddGroupToRolesOptions) (*Group, error)

func (*Store) AddGroupToUsers

func (s *Store) AddGroupToUsers(ctx context.Context, options *AddGroupToUsersOptions) (*Group, error)

func (*Store) AddRoleToGroups

func (s *Store) AddRoleToGroups(ctx context.Context, options *AddRoleToGroupsOptions) (*Role, error)

func (*Store) AddRoleToUsers

func (s *Store) AddRoleToUsers(ctx context.Context, options *AddRoleToUsersOptions) (*Role, error)

func (*Store) AddUserToGroups

func (s *Store) AddUserToGroups(ctx context.Context, options *AddUserToGroupsOptions) error

func (*Store) AddUserToRoles

func (s *Store) AddUserToRoles(ctx context.Context, options *AddUserToRolesOptions) error

func (*Store) CountGroups

func (s *Store) CountGroups(ctx context.Context) (uint64, error)

func (*Store) CountRoles

func (s *Store) CountRoles(ctx context.Context) (uint64, error)

func (*Store) CreateGroup

func (s *Store) CreateGroup(ctx context.Context, r *Group) error

func (*Store) CreateRole

func (s *Store) CreateRole(ctx context.Context, r *Role) error

func (*Store) DeleteGroup

func (s *Store) DeleteGroup(ctx context.Context, id string) error

func (*Store) DeleteRole

func (s *Store) DeleteRole(ctx context.Context, id string) error

func (*Store) DeleteUserGroup

func (s *Store) DeleteUserGroup(ctx context.Context, userID string) error

func (*Store) DeleteUserRole

func (s *Store) DeleteUserRole(ctx context.Context, userID string) error

func (*Store) GetGroupByID

func (s *Store) GetGroupByID(ctx context.Context, id string) (*Group, error)

func (*Store) GetGroupByKey

func (s *Store) GetGroupByKey(ctx context.Context, key string) (*Group, error)

func (*Store) GetManyGroups

func (s *Store) GetManyGroups(ctx context.Context, ids []string) ([]*Group, error)

func (*Store) GetManyGroupsByKeys

func (s *Store) GetManyGroupsByKeys(ctx context.Context, keys []string) ([]*Group, error)

func (*Store) GetManyRoles

func (s *Store) GetManyRoles(ctx context.Context, ids []string) ([]*Role, error)

func (*Store) GetManyRolesByKeys

func (s *Store) GetManyRolesByKeys(ctx context.Context, keys []string) ([]*Role, error)

func (*Store) GetManyUsersByIds

func (s *Store) GetManyUsersByIds(ctx context.Context, ids []string) ([]string, error)

func (*Store) GetRoleByID

func (s *Store) GetRoleByID(ctx context.Context, id string) (*Role, error)

func (*Store) GetRoleByKey

func (s *Store) GetRoleByKey(ctx context.Context, key string) (*Role, error)

func (*Store) GetUserByID

func (s *Store) GetUserByID(ctx context.Context, id string) (string, error)

func (*Store) ListAllUserIDsByEffectiveRoleIDs

func (s *Store) ListAllUserIDsByEffectiveRoleIDs(ctx context.Context, roleIDs []string) ([]string, error)

func (*Store) ListAllUserIDsByGroupIDs

func (s *Store) ListAllUserIDsByGroupIDs(ctx context.Context, groupIDs []string) ([]string, error)

func (*Store) ListAllUserIDsByRoleID

func (s *Store) ListAllUserIDsByRoleID(ctx context.Context, roleIDs []string) ([]string, error)

func (*Store) ListEffectiveRolesByUserID

func (s *Store) ListEffectiveRolesByUserID(ctx context.Context, userID string) ([]*Role, error)

func (*Store) ListGroups

func (s *Store) ListGroups(ctx context.Context, options *ListGroupsOptions, pageArgs graphqlutil.PageArgs) ([]*Group, uint64, error)

func (*Store) ListGroupsByRoleID

func (s *Store) ListGroupsByRoleID(ctx context.Context, roleID string) ([]*Group, error)

func (*Store) ListGroupsByUserID

func (s *Store) ListGroupsByUserID(ctx context.Context, userID string) ([]*Group, error)

func (*Store) ListGroupsByUserIDs

func (s *Store) ListGroupsByUserIDs(ctx context.Context, userIDs []string) (map[string][]*Group, error)

func (*Store) ListRoles

func (s *Store) ListRoles(ctx context.Context, options *ListRolesOptions, pageArgs graphqlutil.PageArgs) ([]*Role, uint64, error)

func (*Store) ListRolesByGroupID

func (s *Store) ListRolesByGroupID(ctx context.Context, groupID string) ([]*Role, error)

func (*Store) ListRolesByUserID

func (s *Store) ListRolesByUserID(ctx context.Context, userID string) ([]*Role, error)

func (*Store) ListRolesByUserIDs

func (s *Store) ListRolesByUserIDs(ctx context.Context, userIDs []string) (map[string][]*Role, error)

func (*Store) ListUserIDsByGroupID

func (s *Store) ListUserIDsByGroupID(ctx context.Context, groupID string, pageArgs graphqlutil.PageArgs) ([]string, uint64, error)

func (*Store) ListUserIDsByRoleID

func (s *Store) ListUserIDsByRoleID(ctx context.Context, roleID string, pageArgs graphqlutil.PageArgs) ([]string, uint64, error)

func (*Store) NewGroup

func (s *Store) NewGroup(options *NewGroupOptions) *Group

func (*Store) NewRole

func (s *Store) NewRole(options *NewRoleOptions) *Role

func (*Store) RemoveGroupFromRoles

func (s *Store) RemoveGroupFromRoles(ctx context.Context, options *RemoveGroupFromRolesOptions) (*Group, error)

func (*Store) RemoveGroupFromUsers

func (s *Store) RemoveGroupFromUsers(ctx context.Context, options *RemoveGroupFromUsersOptions) (*Group, error)

func (*Store) RemoveRoleFromGroups

func (s *Store) RemoveRoleFromGroups(ctx context.Context, options *RemoveRoleFromGroupsOptions) (*Role, error)

func (*Store) RemoveRoleFromUsers

func (s *Store) RemoveRoleFromUsers(ctx context.Context, options *RemoveRoleFromUsersOptions) (*Role, error)

func (*Store) RemoveUserFromGroups

func (s *Store) RemoveUserFromGroups(ctx context.Context, options *RemoveUserFromGroupsOptions) error

func (*Store) RemoveUserFromRoles

func (s *Store) RemoveUserFromRoles(ctx context.Context, options *RemoveUserFromRolesOptions) error

func (*Store) ResetUserGroup

func (s *Store) ResetUserGroup(ctx context.Context, options *ResetUserGroupOptions) error

func (*Store) ResetUserRole

func (s *Store) ResetUserRole(ctx context.Context, options *ResetUserRoleOptions) error

func (*Store) UpdateGroup

func (s *Store) UpdateGroup(ctx context.Context, options *UpdateGroupOptions) error

func (*Store) UpdateRole

func (s *Store) UpdateRole(ctx context.Context, options *UpdateRoleOptions) error

type UpdateGroupOptions

type UpdateGroupOptions struct {
	ID             string
	NewKey         *string
	NewName        *string
	NewDescription *string
}

func (*UpdateGroupOptions) RequireUpdate

func (o *UpdateGroupOptions) RequireUpdate() bool

type UpdateRoleOptions

type UpdateRoleOptions struct {
	ID             string
	NewKey         *string
	NewName        *string
	NewDescription *string
}

func (*UpdateRoleOptions) RequireUpdate

func (o *UpdateRoleOptions) RequireUpdate() bool

Jump to

Keyboard shortcuts

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