Documentation
¶
Overview ¶
Package user provides user and group management operations.
Password and SSH key operations accept values inline in the request body rather than via Object Store + file.Deployer (which cron and certificate providers use). These are small values attached to a user account, not file deployments — Object Store would add unnecessary ceremony. SSH key fingerprints serve as the natural identity, so no SHA state tracking is needed.
Index ¶
- type CreateGroupOpts
- type CreateUserOpts
- type Darwin
- func (d *Darwin) AddKey(_ context.Context, _ string, _ SSHKey) (*SSHKeyResult, error)
- func (d *Darwin) ChangePassword(_ context.Context, _ string, _ string) (*Result, error)
- func (d *Darwin) CreateGroup(_ context.Context, _ CreateGroupOpts) (*GroupResult, error)
- func (d *Darwin) CreateUser(_ context.Context, _ CreateUserOpts) (*Result, error)
- func (d *Darwin) DeleteGroup(_ context.Context, _ string) (*GroupResult, error)
- func (d *Darwin) DeleteUser(_ context.Context, _ string) (*Result, error)
- func (d *Darwin) GetGroup(_ context.Context, _ string) (*Group, error)
- func (d *Darwin) GetUser(_ context.Context, _ string) (*User, error)
- func (d *Darwin) ListGroups(_ context.Context) ([]Group, error)
- func (d *Darwin) ListKeys(_ context.Context, _ string) ([]SSHKey, error)
- func (d *Darwin) ListUsers(_ context.Context) ([]User, error)
- func (d *Darwin) RemoveKey(_ context.Context, _ string, _ string) (*SSHKeyResult, error)
- func (d *Darwin) UpdateGroup(_ context.Context, _ string, _ UpdateGroupOpts) (*GroupResult, error)
- func (d *Darwin) UpdateUser(_ context.Context, _ string, _ UpdateUserOpts) (*Result, error)
- type Debian
- func (d *Debian) AddKey(ctx context.Context, username string, key SSHKey) (*SSHKeyResult, error)
- func (d *Debian) ChangePassword(ctx context.Context, name string, password string) (*Result, error)
- func (d *Debian) CreateGroup(ctx context.Context, opts CreateGroupOpts) (*GroupResult, error)
- func (d *Debian) CreateUser(ctx context.Context, opts CreateUserOpts) (*Result, error)
- func (d *Debian) DeleteGroup(ctx context.Context, name string) (*GroupResult, error)
- func (d *Debian) DeleteUser(ctx context.Context, name string) (*Result, error)
- func (d *Debian) GetGroup(ctx context.Context, name string) (*Group, error)
- func (d *Debian) GetUser(ctx context.Context, name string) (*User, error)
- func (d *Debian) ListGroups(ctx context.Context) ([]Group, error)
- func (d *Debian) ListKeys(ctx context.Context, username string) ([]SSHKey, error)
- func (d *Debian) ListUsers(ctx context.Context) ([]User, error)
- func (d *Debian) RemoveKey(ctx context.Context, username string, fingerprint string) (*SSHKeyResult, error)
- func (d *Debian) UpdateGroup(ctx context.Context, name string, opts UpdateGroupOpts) (*GroupResult, error)
- func (d *Debian) UpdateUser(ctx context.Context, name string, opts UpdateUserOpts) (*Result, error)
- type Group
- type GroupResult
- type Linux
- func (l *Linux) AddKey(_ context.Context, _ string, _ SSHKey) (*SSHKeyResult, error)
- func (l *Linux) ChangePassword(_ context.Context, _ string, _ string) (*Result, error)
- func (l *Linux) CreateGroup(_ context.Context, _ CreateGroupOpts) (*GroupResult, error)
- func (l *Linux) CreateUser(_ context.Context, _ CreateUserOpts) (*Result, error)
- func (l *Linux) DeleteGroup(_ context.Context, _ string) (*GroupResult, error)
- func (l *Linux) DeleteUser(_ context.Context, _ string) (*Result, error)
- func (l *Linux) GetGroup(_ context.Context, _ string) (*Group, error)
- func (l *Linux) GetUser(_ context.Context, _ string) (*User, error)
- func (l *Linux) ListGroups(_ context.Context) ([]Group, error)
- func (l *Linux) ListKeys(_ context.Context, _ string) ([]SSHKey, error)
- func (l *Linux) ListUsers(_ context.Context) ([]User, error)
- func (l *Linux) RemoveKey(_ context.Context, _ string, _ string) (*SSHKeyResult, error)
- func (l *Linux) UpdateGroup(_ context.Context, _ string, _ UpdateGroupOpts) (*GroupResult, error)
- func (l *Linux) UpdateUser(_ context.Context, _ string, _ UpdateUserOpts) (*Result, error)
- type Provider
- type Result
- type SSHKey
- type SSHKeyResult
- type UpdateGroupOpts
- type UpdateUserOpts
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CreateGroupOpts ¶
type CreateGroupOpts struct {
Name string `json:"name"`
GID int `json:"gid,omitempty"`
System bool `json:"system,omitempty"`
}
CreateGroupOpts contains options for creating a new group.
type CreateUserOpts ¶
type CreateUserOpts struct {
Name string `json:"name"`
UID int `json:"uid,omitempty"`
GID int `json:"gid,omitempty"`
Home string `json:"home,omitempty"`
Shell string `json:"shell,omitempty"`
Groups []string `json:"groups,omitempty"`
Password string `json:"password,omitempty"`
System bool `json:"system,omitempty"`
}
CreateUserOpts contains options for creating a new user.
type Darwin ¶
type Darwin struct{}
Darwin implements the Provider interface for Darwin (macOS). All methods return ErrUnsupported as user/group management is not available on macOS.
func NewDarwinProvider ¶
func NewDarwinProvider() *Darwin
NewDarwinProvider factory to create a new Darwin instance.
func (*Darwin) ChangePassword ¶
ChangePassword returns ErrUnsupported on Darwin.
func (*Darwin) CreateGroup ¶
func (d *Darwin) CreateGroup( _ context.Context, _ CreateGroupOpts, ) (*GroupResult, error)
CreateGroup returns ErrUnsupported on Darwin.
func (*Darwin) CreateUser ¶
CreateUser returns ErrUnsupported on Darwin.
func (*Darwin) DeleteGroup ¶
DeleteGroup returns ErrUnsupported on Darwin.
func (*Darwin) DeleteUser ¶
DeleteUser returns ErrUnsupported on Darwin.
func (*Darwin) ListGroups ¶
ListGroups returns ErrUnsupported on Darwin.
func (*Darwin) UpdateGroup ¶
func (d *Darwin) UpdateGroup( _ context.Context, _ string, _ UpdateGroupOpts, ) (*GroupResult, error)
UpdateGroup returns ErrUnsupported on Darwin.
func (*Darwin) UpdateUser ¶
UpdateUser returns ErrUnsupported on Darwin.
type Debian ¶
type Debian struct {
provider.FactsAware
// contains filtered or unexported fields
}
Debian implements the Provider interface for Debian-family systems.
func NewDebianProvider ¶
NewDebianProvider factory to create a new Debian instance.
func (*Debian) ChangePassword ¶
func (d *Debian) ChangePassword( ctx context.Context, name string, password string, ) (*Result, error)
ChangePassword changes a user's password.
func (*Debian) CreateGroup ¶
func (d *Debian) CreateGroup( ctx context.Context, opts CreateGroupOpts, ) (*GroupResult, error)
CreateGroup creates a new system group.
func (*Debian) CreateUser ¶
CreateUser creates a new user account.
func (*Debian) DeleteGroup ¶
DeleteGroup removes a system group.
func (*Debian) DeleteUser ¶
DeleteUser removes a user account and its home directory.
func (*Debian) ListGroups ¶
ListGroups returns all system groups.
func (*Debian) RemoveKey ¶
func (d *Debian) RemoveKey( ctx context.Context, username string, fingerprint string, ) (*SSHKeyResult, error)
RemoveKey removes an SSH public key by fingerprint from the user's authorized_keys file.
func (*Debian) UpdateGroup ¶
func (d *Debian) UpdateGroup( ctx context.Context, name string, opts UpdateGroupOpts, ) (*GroupResult, error)
UpdateGroup updates group membership.
func (*Debian) UpdateUser ¶
func (d *Debian) UpdateUser( ctx context.Context, name string, opts UpdateUserOpts, ) (*Result, error)
UpdateUser modifies an existing user account.
type Group ¶
type Group struct {
Name string `json:"name"`
GID int `json:"gid"`
Members []string `json:"members,omitempty"`
}
Group represents a system group.
type GroupResult ¶
type GroupResult struct {
Name string `json:"name"`
Changed bool `json:"changed"`
Error string `json:"error,omitempty"`
}
GroupResult represents the result of a group mutation operation.
type Linux ¶
type Linux struct{}
Linux implements the Provider interface for generic Linux. All methods return ErrUnsupported; use the Debian provider for Debian-family systems.
func NewLinuxProvider ¶
func NewLinuxProvider() *Linux
NewLinuxProvider factory to create a new Linux instance.
func (*Linux) ChangePassword ¶
ChangePassword returns ErrUnsupported on generic Linux.
func (*Linux) CreateGroup ¶
func (l *Linux) CreateGroup( _ context.Context, _ CreateGroupOpts, ) (*GroupResult, error)
CreateGroup returns ErrUnsupported on generic Linux.
func (*Linux) CreateUser ¶
CreateUser returns ErrUnsupported on generic Linux.
func (*Linux) DeleteGroup ¶
DeleteGroup returns ErrUnsupported on generic Linux.
func (*Linux) DeleteUser ¶
DeleteUser returns ErrUnsupported on generic Linux.
func (*Linux) ListGroups ¶
ListGroups returns ErrUnsupported on generic Linux.
func (*Linux) UpdateGroup ¶
func (l *Linux) UpdateGroup( _ context.Context, _ string, _ UpdateGroupOpts, ) (*GroupResult, error)
UpdateGroup returns ErrUnsupported on generic Linux.
func (*Linux) UpdateUser ¶
UpdateUser returns ErrUnsupported on generic Linux.
type Provider ¶
type Provider interface {
ListUsers(ctx context.Context) ([]User, error)
GetUser(ctx context.Context, name string) (*User, error)
CreateUser(ctx context.Context, opts CreateUserOpts) (*Result, error)
UpdateUser(ctx context.Context, name string, opts UpdateUserOpts) (*Result, error)
DeleteUser(ctx context.Context, name string) (*Result, error)
ChangePassword(ctx context.Context, name string, password string) (*Result, error)
ListGroups(ctx context.Context) ([]Group, error)
GetGroup(ctx context.Context, name string) (*Group, error)
CreateGroup(ctx context.Context, opts CreateGroupOpts) (*GroupResult, error)
UpdateGroup(ctx context.Context, name string, opts UpdateGroupOpts) (*GroupResult, error)
DeleteGroup(ctx context.Context, name string) (*GroupResult, error)
ListKeys(ctx context.Context, username string) ([]SSHKey, error)
AddKey(ctx context.Context, username string, key SSHKey) (*SSHKeyResult, error)
RemoveKey(ctx context.Context, username string, fingerprint string) (*SSHKeyResult, error)
}
Provider implements the methods to manage users and groups.
type Result ¶
type Result struct {
Name string `json:"name"`
Changed bool `json:"changed"`
Error string `json:"error,omitempty"`
}
Result represents the result of a user mutation operation.
type SSHKey ¶
type SSHKey struct {
Type string `json:"type"`
Fingerprint string `json:"fingerprint"`
Comment string `json:"comment,omitempty"`
RawLine string `json:"raw_line,omitempty"`
}
SSHKey represents an SSH public key from authorized_keys.
type SSHKeyResult ¶
type SSHKeyResult struct {
Changed bool `json:"changed"`
}
SSHKeyResult represents the result of an SSH key mutation operation.
type UpdateGroupOpts ¶
type UpdateGroupOpts struct {
Members []string `json:"members,omitempty"`
}
UpdateGroupOpts contains options for updating an existing group.