Documentation
¶
Index ¶
- Variables
- func AddIdentity(id Identity, kind string) error
- func GetAuthType(username string) (string, error)
- func GetNextAvailableId(kind string) (uint, error)
- func HashPassword(password string) string
- func IsAccountLocked(username string) bool
- func UpdatePassword(identity, oldpassword, newpassword string) error
- type Auth
- type AuthConfig
- type Capability
- type CapabilityConfig
- type Identity
- func Authenticate(username, password string) (*Identity, error)
- func AuthenticateByID(uid uint, password string) (*Identity, error)
- func GetCapabilityMembers(capName string) ([]*Identity, error)
- func ListIdentities() ([]*Identity, error)
- func LookupByID(uid uint) (*Identity, error)
- func LookupByName(name string) (*Identity, error)
- type IdentityConfig
Constants ¶
This section is empty.
Variables ¶
var ( ErrUserNotFound = errors.New("user not found") ErrGroupNotFound = errors.New("group not found") ErrAuthNotFound = errors.New("auth entry not found") ErrInvalidCredentials = errors.New("invalid credentials") ErrAccountLocked = errors.New("account is locked") ErrInvalidIdentityKind = errors.New("invalid identity kind") ErrNoAvailableID = errors.New("no available id in range") )
Common errors
Functions ¶
func AddIdentity ¶
AddIdentity register new identity into system config
func GetAuthType ¶
GetAuthType returns the authentication type for a user
func GetNextAvailableId ¶
func HashPassword ¶
HashPassword creates a hash for a password
func IsAccountLocked ¶
IsAccountLocked checks if a user account is locked
func UpdatePassword ¶
UpdatePassword update the password
Types ¶
type Auth ¶
type Auth struct {
ID uint `json:"id"`
Name string `json:"name"`
Type string `json:"type"` // "password", "none", "locked"
Hash string `json:"hash,omitempty"`
}
Auth represents authentication info from auth.conf
type AuthConfig ¶
type AuthConfig struct {
Entries []Auth `json:"entries"`
}
AuthConfig holds all authentication entries
type Capability ¶
Capability represents a Unix group mapping from capabilities.conf
func ListCapabilities ¶
func ListCapabilities() ([]*Capability, error)
ListCapabilities returns all capabilities in the system
func LookupCapabilityByID ¶
func LookupCapabilityByID(gid uint) (*Capability, error)
LookupCapabilityByID finds a capability by its numeric ID
func LookupCapabilityByName ¶
func LookupCapabilityByName(name string) (*Capability, error)
LookupCapabilityByName finds a capability by its name
type CapabilityConfig ¶
type CapabilityConfig struct {
Capabilities []Capability `json:"capabilities"`
}
CapabilityConfig holds all capabilities (group mappings)
type Identity ¶
type Identity struct {
ID uint `json:"id"`
Name string `json:"name"`
Capabilities []string `json:"capabilities"`
Home string `json:"home,omitempty"`
Shell string `json:"shell,omitempty"`
}
Identity represents a user account from identity.conf
func Authenticate ¶
Authenticate verifies credentials and returns the identity
func AuthenticateByID ¶
AuthenticateByID verifies credentials using user ID
func GetCapabilityMembers ¶
GetCapabilityMembers returns all identities who have a capability
func ListIdentities ¶
ListIdentities returns all identities in the system
func LookupByID ¶
LookupByID finds an identity by their numeric ID
func LookupByName ¶
LookupByName finds an identity by their username
func (*Identity) GetGroupIDs ¶
GetGroupIDs returns all group IDs for the identity
func (*Identity) GetGroups ¶
func (i *Identity) GetGroups() ([]*Capability, error)
GetGroups returns all Unix groups for this identity
func (*Identity) HasCapability ¶
HasCapability checks if an identity has a specific capability
type IdentityConfig ¶
type IdentityConfig struct {
Identities []Identity `json:"identities"`
}
IdentityConfig holds all identities
func LoadIdentityConfig ¶
func LoadIdentityConfig() (*IdentityConfig, error)
LoadIdentityConfig reads and parses the identity config file