rolesgroups

package
v0.0.0-...-c4f7e29 Latest Latest
Warning

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

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

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(options *AddGroupToRolesOptions) (*model.Group, error)

func (*Commands) AddGroupToUsers

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

func (*Commands) AddRoleToGroups

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

func (*Commands) AddRoleToUsers

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

func (*Commands) AddUserToGroups

func (c *Commands) AddUserToGroups(options *AddUserToGroupsOptions) error

func (*Commands) AddUserToRoles

func (c *Commands) AddUserToRoles(options *AddUserToRolesOptions) error

func (*Commands) CreateGroup

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

func (*Commands) CreateRole

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

func (*Commands) DeleteGroup

func (c *Commands) DeleteGroup(id string) error

func (*Commands) DeleteRole

func (c *Commands) DeleteRole(id string) error

func (*Commands) DeleteUserGroup

func (c *Commands) DeleteUserGroup(userID string) error

func (*Commands) DeleteUserRole

func (c *Commands) DeleteUserRole(userID string) error

func (*Commands) RemoveGroupFromRoles

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

func (*Commands) RemoveGroupFromUsers

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

func (*Commands) RemoveRoleFromGroups

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

func (*Commands) RemoveRoleFromUsers

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

func (*Commands) RemoveUserFromGroups

func (c *Commands) RemoveUserFromGroups(options *RemoveUserFromGroupsOptions) error

func (*Commands) RemoveUserFromRoles

func (c *Commands) RemoveUserFromRoles(options *RemoveUserFromRolesOptions) error

func (*Commands) ResetUserGroup

func (c *Commands) ResetUserGroup(options *ResetUserGroupOptions) error

func (*Commands) ResetUserRole

func (c *Commands) ResetUserRole(options *ResetUserRoleOptions) error

func (*Commands) UpdateGroup

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

func (*Commands) UpdateRole

func (c *Commands) UpdateRole(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() (uint64, error)

func (*Queries) CountRoles

func (q *Queries) CountRoles() (uint64, error)

func (*Queries) GetGroup

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

func (*Queries) GetManyGroups

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

func (*Queries) GetManyRoles

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

func (*Queries) GetRole

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

func (*Queries) ListAllGroupsByKeys

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

func (*Queries) ListAllRolesByKeys

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

func (*Queries) ListAllUserIDsByEffectiveRoleIDs

func (q *Queries) ListAllUserIDsByEffectiveRoleIDs(roleIDs []string) ([]string, error)

func (*Queries) ListAllUserIDsByGroupIDs

func (q *Queries) ListAllUserIDsByGroupIDs(groupIDs []string) ([]string, error)

func (*Queries) ListAllUserIDsByGroupKeys

func (q *Queries) ListAllUserIDsByGroupKeys(groupKeys []string) ([]string, error)

func (*Queries) ListAllUserIDsByRoleIDs

func (q *Queries) ListAllUserIDsByRoleIDs(roleIDs []string) ([]string, error)

func (*Queries) ListEffectiveRolesByUserID

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

func (*Queries) ListGroups

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

func (*Queries) ListGroupsByRoleID

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

func (*Queries) ListGroupsByUserID

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

func (*Queries) ListGroupsByUserIDs

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

func (*Queries) ListRoles

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

func (*Queries) ListRolesByGroupID

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

func (*Queries) ListRolesByUserID

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

func (*Queries) ListRolesByUserIDs

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

func (*Queries) ListUserIDsByGroupID

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

func (*Queries) ListUserIDsByRoleID

func (q *Queries) ListUserIDsByRoleID(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(options *AddGroupToRolesOptions) (*Group, error)

func (*Store) AddGroupToUsers

func (s *Store) AddGroupToUsers(options *AddGroupToUsersOptions) (*Group, error)

func (*Store) AddRoleToGroups

func (s *Store) AddRoleToGroups(options *AddRoleToGroupsOptions) (*Role, error)

func (*Store) AddRoleToUsers

func (s *Store) AddRoleToUsers(options *AddRoleToUsersOptions) (*Role, error)

func (*Store) AddUserToGroups

func (s *Store) AddUserToGroups(options *AddUserToGroupsOptions) error

func (*Store) AddUserToRoles

func (s *Store) AddUserToRoles(options *AddUserToRolesOptions) error

func (*Store) CountGroups

func (s *Store) CountGroups() (uint64, error)

func (*Store) CountRoles

func (s *Store) CountRoles() (uint64, error)

func (*Store) CreateGroup

func (s *Store) CreateGroup(r *Group) error

func (*Store) CreateRole

func (s *Store) CreateRole(r *Role) error

func (*Store) DeleteGroup

func (s *Store) DeleteGroup(id string) error

func (*Store) DeleteRole

func (s *Store) DeleteRole(id string) error

func (*Store) DeleteUserGroup

func (s *Store) DeleteUserGroup(userID string) error

func (*Store) DeleteUserRole

func (s *Store) DeleteUserRole(userID string) error

func (*Store) GetGroupByID

func (s *Store) GetGroupByID(id string) (*Group, error)

func (*Store) GetGroupByKey

func (s *Store) GetGroupByKey(key string) (*Group, error)

func (*Store) GetManyGroups

func (s *Store) GetManyGroups(ids []string) ([]*Group, error)

func (*Store) GetManyGroupsByKeys

func (s *Store) GetManyGroupsByKeys(keys []string) ([]*Group, error)

func (*Store) GetManyRoles

func (s *Store) GetManyRoles(ids []string) ([]*Role, error)

func (*Store) GetManyRolesByKeys

func (s *Store) GetManyRolesByKeys(keys []string) ([]*Role, error)

func (*Store) GetManyUsersByIds

func (s *Store) GetManyUsersByIds(ids []string) ([]string, error)

func (*Store) GetRoleByID

func (s *Store) GetRoleByID(id string) (*Role, error)

func (*Store) GetRoleByKey

func (s *Store) GetRoleByKey(key string) (*Role, error)

func (*Store) GetUserByID

func (s *Store) GetUserByID(id string) (string, error)

func (*Store) ListAllUserIDsByEffectiveRoleIDs

func (s *Store) ListAllUserIDsByEffectiveRoleIDs(roleIDs []string) ([]string, error)

func (*Store) ListAllUserIDsByGroupIDs

func (s *Store) ListAllUserIDsByGroupIDs(groupIDs []string) ([]string, error)

func (*Store) ListAllUserIDsByRoleID

func (s *Store) ListAllUserIDsByRoleID(roleIDs []string) ([]string, error)

func (*Store) ListEffectiveRolesByUserID

func (s *Store) ListEffectiveRolesByUserID(userID string) ([]*Role, error)

func (*Store) ListGroups

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

func (*Store) ListGroupsByRoleID

func (s *Store) ListGroupsByRoleID(roleID string) ([]*Group, error)

func (*Store) ListGroupsByUserID

func (s *Store) ListGroupsByUserID(userID string) ([]*Group, error)

func (*Store) ListGroupsByUserIDs

func (s *Store) ListGroupsByUserIDs(userIDs []string) (map[string][]*Group, error)

func (*Store) ListRoles

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

func (*Store) ListRolesByGroupID

func (s *Store) ListRolesByGroupID(groupID string) ([]*Role, error)

func (*Store) ListRolesByUserID

func (s *Store) ListRolesByUserID(userID string) ([]*Role, error)

func (*Store) ListRolesByUserIDs

func (s *Store) ListRolesByUserIDs(userIDs []string) (map[string][]*Role, error)

func (*Store) ListUserIDsByGroupID

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

func (*Store) ListUserIDsByRoleID

func (s *Store) ListUserIDsByRoleID(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(options *RemoveGroupFromRolesOptions) (*Group, error)

func (*Store) RemoveGroupFromUsers

func (s *Store) RemoveGroupFromUsers(options *RemoveGroupFromUsersOptions) (*Group, error)

func (*Store) RemoveRoleFromGroups

func (s *Store) RemoveRoleFromGroups(options *RemoveRoleFromGroupsOptions) (*Role, error)

func (*Store) RemoveRoleFromUsers

func (s *Store) RemoveRoleFromUsers(options *RemoveRoleFromUsersOptions) (*Role, error)

func (*Store) RemoveUserFromGroups

func (s *Store) RemoveUserFromGroups(options *RemoveUserFromGroupsOptions) error

func (*Store) RemoveUserFromRoles

func (s *Store) RemoveUserFromRoles(options *RemoveUserFromRolesOptions) error

func (*Store) ResetUserGroup

func (s *Store) ResetUserGroup(options *ResetUserGroupOptions) error

func (*Store) ResetUserRole

func (s *Store) ResetUserRole(options *ResetUserRoleOptions) error

func (*Store) UpdateGroup

func (s *Store) UpdateGroup(options *UpdateGroupOptions) error

func (*Store) UpdateRole

func (s *Store) UpdateRole(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