Documentation
¶
Overview ¶
Package db handles transaction with an underlying database to store user and group information.
Index ¶
- func MigrateFromBBoltToSQLite(dbDir string) error
- func RemoveDB(dbDir string) error
- func Z_ForTests_CreateDBFromYAML(src, destDir string) error
- func Z_ForTests_CreateDBFromYAMLReader(r io.Reader, destDir string) error
- func Z_ForTests_DumpNormalizedYAML(c *Manager) (string, error)
- func Z_ForTests_GetGroupFile() string
- func Z_ForTests_SetGroupFile(groupFilePath string)
- type GroupRow
- type GroupWithMembers
- type Manager
- func (m *Manager) AllGroupsWithMembers() (_ []GroupWithMembers, err error)
- func (m *Manager) AllUsers() ([]UserRow, error)
- func (m *Manager) Close() error
- func (m *Manager) DeleteUser(uid uint32) error
- func (m *Manager) GroupByID(gid uint32) (GroupRow, error)
- func (m *Manager) GroupByName(name string) (GroupRow, error)
- func (m *Manager) GroupByUGID(ugid string) (GroupRow, error)
- func (m *Manager) GroupWithMembersByID(gid uint32) (_ GroupWithMembers, err error)
- func (m *Manager) GroupWithMembersByName(name string) (_ GroupWithMembers, err error)
- func (m *Manager) RemoveUserFromGroup(uid, gid uint32) error
- func (m *Manager) UpdateBrokerForUser(username, brokerID string) error
- func (m *Manager) UpdateUserEntry(user UserRow, authdGroups []GroupRow, localGroups []string) (err error)
- func (m *Manager) UserByID(uid uint32) (UserRow, error)
- func (m *Manager) UserByName(name string) (UserRow, error)
- func (m *Manager) UserGroups(uid uint32) ([]GroupRow, error)
- func (m *Manager) UserLocalGroups(uid uint32) ([]string, error)
- type NoDataFoundError
- type UserRow
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MigrateFromBBoltToSQLite ¶
MigrateFromBBoltToSQLite migrates data from bbolt to SQLite.
func Z_ForTests_CreateDBFromYAML ¶
Z_ForTests_CreateDBFromYAML creates the bbolt database inside destDir and loads the src file content into it.
nolint:revive,nolintlint // We want to use underscores in the function name here.
func Z_ForTests_CreateDBFromYAMLReader ¶
Z_ForTests_CreateDBFromYAML creates the bbolt database inside destDir and loads the src file content into it.
nolint:revive,nolintlint // We want to use underscores in the function name here.
func Z_ForTests_DumpNormalizedYAML ¶
Z_ForTests_DumpNormalizedYAML gets the content of the database, normalizes it (so that it can be compared with a golden file) and returns it as a YAML string.
nolint:revive,nolintlint // We want to use underscores in the function name here.
func Z_ForTests_GetGroupFile ¶ added in v0.5.1
func Z_ForTests_GetGroupFile() string
Z_ForTests_GetGroupFile returns the path to the group file.
nolint:revive,nolintlint // We want to use underscores in the function name here.
func Z_ForTests_SetGroupFile ¶
func Z_ForTests_SetGroupFile(groupFilePath string)
Z_ForTests_SetGroupFile sets the group file to the provided path.
nolint:revive,nolintlint // We want to use underscores in the function name here.
Types ¶
type GroupWithMembers ¶
GroupWithMembers is a GroupRow with a list of users that are members of the group.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager is an abstraction to interact with the database.
func (*Manager) AllGroupsWithMembers ¶
func (m *Manager) AllGroupsWithMembers() (_ []GroupWithMembers, err error)
AllGroupsWithMembers returns all groups with their members.
func (*Manager) DeleteUser ¶
DeleteUser removes the user from the database.
func (*Manager) GroupByID ¶
GroupByID returns the group with the given group ID or a NoDataFoundError if no group was found.
func (*Manager) GroupByName ¶
GroupByName returns the group with the given name or a NoDataFoundError if no group was found.
func (*Manager) GroupByUGID ¶
GroupByUGID returns the group with the given UGID or a NoDataFoundError if no group was found.
func (*Manager) GroupWithMembersByID ¶
func (m *Manager) GroupWithMembersByID(gid uint32) (_ GroupWithMembers, err error)
GroupWithMembersByID returns the group with the given group ID with a list of users that are members of the group.
func (*Manager) GroupWithMembersByName ¶
func (m *Manager) GroupWithMembersByName(name string) (_ GroupWithMembers, err error)
GroupWithMembersByName returns the group with the given name with a list of users that are members of the group.
func (*Manager) RemoveUserFromGroup ¶
RemoveUserFromGroup removes a user from a group.
func (*Manager) UpdateBrokerForUser ¶
UpdateBrokerForUser updates the last broker the user successfully authenticated with.
func (*Manager) UpdateUserEntry ¶
func (m *Manager) UpdateUserEntry(user UserRow, authdGroups []GroupRow, localGroups []string) (err error)
UpdateUserEntry inserts or updates user and group records from the user information.
func (*Manager) UserByID ¶
UserByID returns a user matching this uid or an error if the database is corrupted or no entry was found.
func (*Manager) UserByName ¶
UserByName returns a user matching this name or an error if the database is corrupted or no entry was found.
func (*Manager) UserGroups ¶
UserGroups returns all groups for a given user or an error if the database is corrupted or no entry was found.
type NoDataFoundError ¶
type NoDataFoundError struct {
// contains filtered or unexported fields
}
NoDataFoundError is returned when we didn’t find a matching entry.
func (NoDataFoundError) Error ¶
func (err NoDataFoundError) Error() string
Error implements the error interface.
func (NoDataFoundError) Is ¶
func (NoDataFoundError) Is(target error) bool
Is makes this error insensitive to the key and table names.
type UserRow ¶
type UserRow struct {
Name string
UID uint32
GID uint32
Gecos string // Gecos is an optional field. It can be empty.
Dir string
Shell string
// BrokerID specifies the broker the user last successfully authenticated with.
BrokerID string `yaml:"broker_id,omitempty"`
}
UserRow represents a user row in the database.