user

package
v0.0.0-...-05f81da Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2024 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MaxUsernameLength is the longest possible username
	MaxUsernameLength = 64
	// MaxLoginLength is the longest possible login
	MaxLoginLength = 31
	// MinPasswordLength is the shortest possible password
	MinPasswordLength = 8
	// MaxPasswordLength is the shortest possible password
	MaxPasswordLength = 255

	// UsernameCharRequirementMessage is basic username requirements
	UsernameCharRequirementMessage = "Username must contain only numbers, letters, commas, - or _"

	// UsernameMaxRequirementMessage is the basic username requirements
	UsernameMaxRequirementMessage = "UserName maximum length is %d"

	// LoginNonEmptyRequirementMessage is basic login requirements
	LoginNonEmptyRequirementMessage = "Login is required"

	// LoginMaxRequirementMessage is the basic login requirements
	LoginMaxRequirementMessage = "Login maximum length is %d"

	// LoginRegexRequirementMessage is the basic password requirements
	LoginRegexRequirementMessage = "Login must contain only numbers, letters, -, . or _"

	// PasswordMinRequirementMessage is the basic password requirements
	PasswordMinRequirementMessage = "Password must be at least %d characters long"

	// PasswordMaxRequirementMessage is the basic password requirements
	PasswordMaxRequirementMessage = "Password may be at most %d characters long"
)
View Source
const (

	// RequiredBundle the bundle needed to enable non-root user accounts
	RequiredBundle = "sysadmin-basic"
)

Variables

This section is empty.

Functions

func Apply

func Apply(rootDir string, users []*User) error

Apply creates the user and sets their password into chroot'ed rootDir

func IsSysDefaultUser

func IsSysDefaultUser(login string) (bool, error)

IsSysDefaultUser checks if a given login is in the list of default users

func IsValidLogin

func IsValidLogin(login string) (bool, string)

IsValidLogin checks the minimum login requirements

func IsValidPassword

func IsValidPassword(pwd string) (bool, string)

IsValidPassword checks the minimum password requirements

func IsValidUsername

func IsValidUsername(username string) (bool, string)

IsValidUsername checks the username restrictions

Types

type User

type User struct {
	Login    string   `yaml:"login,omitempty"`
	UserName string   `yaml:"username,omitempty,flow"`
	Password string   `yaml:"password,omitempty,flow"`
	Admin    bool     `yaml:"admin,omitempty,flow"`
	SSHKeys  []string `yaml:"ssh-keys,omitempty,flow"`
}

User abstracts a target system definition

func NewUser

func NewUser(login string, username string, pwd string, admin bool) (*User, error)

NewUser creates/allocates a new user handle

func (*User) Equals

func (u *User) Equals(usr *User) bool

Equals returns true if u and usr point to the same struct or if both have the same Login string

func (*User) SetPassword

func (u *User) SetPassword(pwd string) error

SetPassword sets a users password

type Validator

type Validator struct {
	Login    string
	UserName string
	Password string
}

Validator abstracts user validation efforts

func NewValidator

func NewValidator(login string,
	username string, password string) *Validator

NewValidator creates/allocates a new user validation

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL