Documentation ¶
Index ¶
- Constants
- func IsValidGroupName(name string) bool
- func IsValidUserName(name string) bool
- func NewEtcdConfig() *etcdutil.Config
- type Client
- func (c Client) AddGroup(ctx context.Context, name string) error
- func (c Client) AddUser(ctx context.Context, user *User) error
- func (c Client) GetConfig(ctx context.Context) (*Config, int64, error)
- func (c Client) GetUser(ctx context.Context, name string) (*User, int64, error)
- func (c Client) ListGroups(ctx context.Context) ([]Group, error)
- func (c Client) ListLocked(ctx context.Context) ([]string, error)
- func (c Client) ListUsers(ctx context.Context) ([]string, error)
- func (c Client) Lock(ctx context.Context, name string) error
- func (c Client) RemoveGroup(ctx context.Context, name string) error
- func (c Client) RemoveUser(ctx context.Context, name string) error
- func (c Client) SetConfig(ctx context.Context, cfg *Config, rev int64) error
- func (c Client) Unlock(ctx context.Context, name string) error
- func (c Client) UpdateUser(ctx context.Context, user *User, rev int64) error
- type Config
- type Database
- type Group
- type Syncer
- type User
Constants ¶
const ( KeyConfig = "config" KeyLastUID = "last-uid" KeyLastGID = "last-gid" KeyUsers = "users/" KeyDeletedUsers = "deleted-users/" KeyGroups = "groups/" KeyDeletedGroups = "deleted-groups/" KeyLocked = "locked/" )
Internal schema keys.
const ( // ErrCASFailure indicates compare-and-swap failure. ErrCASFailure = errString("conflicted") // ErrNotFound indicates an object was not found in the database. ErrNotFound = errString("not found") // ErrExists indicates that an object with the same key already exists. ErrExists = errString("already exists") )
const (
// DefaultShell is the default shell program.
DefaultShell = "/bin/bash"
)
const (
// Version of etcdpasswd
Version = "1.1.1-rc.3"
)
Variables ¶
This section is empty.
Functions ¶
func IsValidGroupName ¶
IsValidGroupName returns true if name is valid for etcdpasswd managed group.
func IsValidUserName ¶
IsValidUserName returns true if name is valid for etcdpasswd managed user.
func NewEtcdConfig ¶
NewEtcdConfig creates Config with default prefix.
Types ¶
type Client ¶
Client provides high-level API to edit etcd database.
func (Client) AddGroup ¶
AddGroup adds a new managed group to the database. If a group having the same name already exists, ErrExists will be returned.
func (Client) AddUser ¶
AddUser adds a new managed user to the database. If a user having the same name already exists, ErrExists will be returned.
func (Client) GetUser ¶
GetUser looks up named user from the database. If the user is not found, this returns ErrNotFound.
func (Client) ListGroups ¶
ListGroups lists all groups registered in the database. The result is sorted alphabetically.
func (Client) ListLocked ¶
ListLocked lists all password-locked users. The result is sorted alphabetically.
func (Client) ListUsers ¶
ListUsers lists all user names registered in the database. The result is sorted alphabetically.
func (Client) RemoveGroup ¶
RemoveGroup removes an existing managed group. If the group does not exist, ErrNotFound will be returned.
func (Client) RemoveUser ¶
RemoveUser removes an existing managed user. If the user does not exist, ErrNotFound will be returned.
func (Client) SetConfig ¶
SetConfig tries to update *Config. If update was conflicted, ErrCASFailure is returned.
type Config ¶
type Config struct { StartUID int `json:"start-uid"` StartGID int `json:"start-gid"` DefaultGroup string `json:"default-group"` DefaultGroups []string `json:"default-groups"` DefaultShell string `json:"default-shell"` }
Config represents etcdpasswd configurations
type Database ¶
type Database struct { Users []*User Groups []Group DeletedUsers []string DeletedGroups []string LockedUsers []string }
Database is a on-memory snapshot of users and groups in etcd database.
type Syncer ¶
type Syncer interface { // LookupUser looks up the named user in the system. // If the user is not found, this should return (nil, nil). LookupUser(ctx context.Context, name string) (*User, error) // LookupGroup looks up the named group in the system. // If the group is not found, this should return (nil, nil). LookupGroup(ctx context.Context, name string) (*Group, error) // AddUser adds a user to the system. AddUser(ctx context.Context, user *User) error // RemoveUser removes a user from the system. RemoveUser(ctx context.Context, name string) error // SetDisplayName sets the display name of the user. SetDisplayName(ctx context.Context, name, displayName string) error // SetPrimaryGroup sets the primary group of the user. SetPrimaryGroup(ctx context.Context, name, group string) error // SetSupplementalGroups sets the supplemental groups of the user. SetSupplementalGroups(ctx context.Context, name string, groups []string) error // SetShell sets the login shell of the user. SetShell(ctx context.Context, name, shell string) error // SetPubKeys sets SSH authorized keys of the user. SetPubKeys(ctx context.Context, name string, pubkeys []string) error // LockPassword locks the password of the user to prohibit login attempts using password. LockPassword(ctx context.Context, name string) error // AddGroup adds a group to the system. AddGroup(ctx context.Context, group Group) error // RemoveGroup removes a group from the system. RemoveGroup(ctx context.Context, name string) error }
Syncer is an interface for user and group synchronization.