osauth

package
v0.19.1 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Default file path for shadow file.
	DefaultShadowFilename = "/etc/shadow"
	// Default file path for passwd file.
	DefaultPasswdFilename = "/etc/passwd"
)
View Source
var ErrUserNotFound = errors.New("user not found")

ErrUserNotFound is returned when the user is not found in the passwd file.

Functions

func AuthUser

func AuthUser(username, password string) bool

AuthUser attempts to authenticate username and password from DefaultPasswdFilename.

func AuthUserFromShadow added in v0.15.1

func AuthUserFromShadow(username, password string, shadow io.Reader) bool

AuthUserFromShadow attempts to authenticate username and password from file.

func VerifyPasswordHash

func VerifyPasswordHash(hash, password string) bool

VerifyPasswordHash checks if the password match with the hash.

Types

type Backend added in v0.15.1

type Backend interface {
	AuthUser(username, password string) bool
	LookupUser(username string) (*User, error)
}
var DefaultBackend Backend

type User

type User struct {
	UID      uint32 // The user ID of the account.
	GID      uint32 // The group ID of the account.
	Username string // The login name of the account.
	Password string // The hashed password of the account.
	Name     string // The full name of the account owner.
	HomeDir  string // The home directory path of the account.
	Shell    string // The default login shell for the account.
}

func LookupUser

func LookupUser(username string) (*User, error)

LookupUser try to find a [PasswordEntry] for a username from a DefaultPasswdFilename.

func LookupUserFromPasswd added in v0.15.1

func LookupUserFromPasswd(username string, passwd io.Reader) (*User, error)

Lookup try to find a [PasswordEntry] for a username from a passwd file.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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