pass_table

package
v0.28.4 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2026 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HashSHA256 = "sha256"
	HashBcrypt = "bcrypt"
	HashArgon2 = "argon2"

	DefaultHash = HashSHA256

	Argon2Salt = 16
	Argon2Size = 64
)

Variables

View Source
var (
	HashCompute = map[string]FuncHashCompute{
		HashBcrypt: computeBcrypt,
		HashArgon2: computeArgon2,
	}
	HashVerify = map[string]FuncHashVerify{
		HashBcrypt: verifyBcrypt,
		HashArgon2: verifyArgon2,
	}

	Hashes = []string{HashSHA256, HashBcrypt, HashArgon2}
)

Functions

func New

func New(modName, instName string, _, inlineArgs []string) (module.Module, error)

Types

type Auth

type Auth struct {
	// contains filtered or unexported fields
}

func (*Auth) AuthPlain

func (a *Auth) AuthPlain(username, password string) error

func (*Auth) CreateUser

func (a *Auth) CreateUser(username, password string) error

func (*Auth) CreateUserHash

func (a *Auth) CreateUserHash(username, password string, hashAlgo string, opts HashOpts) error

func (*Auth) CreateUserIfNotExists added in v0.12.2

func (a *Auth) CreateUserIfNotExists(username, password string) error

CreateUserIfNotExists creates a user if they don't already exist. This is optimized for concurrent auto-create scenarios during login. Unlike CreateUser, it doesn't fail if the user already exists - it just returns nil (since the goal is to ensure the user exists). It also skips the initial Lookup to avoid the race condition where multiple concurrent requests all see "user not found" and then all try to create.

func (*Auth) DeleteSetting added in v0.15.0

func (a *Auth) DeleteSetting(key string) error

DeleteSetting removes a key from the settings table.

func (*Auth) DeleteUser

func (a *Auth) DeleteUser(username string) error

func (*Auth) GetSetting added in v0.15.0

func (a *Auth) GetSetting(key string) (string, bool, error)

GetSetting retrieves a raw string value from the settings table. Returns (value, true, nil) if found, ("", false, nil) if not set.

func (*Auth) Init

func (a *Auth) Init(cfg *config.Map) error

func (*Auth) InstanceName

func (a *Auth) InstanceName() string

func (*Auth) IsJitRegistrationEnabled added in v0.10.0

func (a *Auth) IsJitRegistrationEnabled() (bool, error)

func (*Auth) IsLoggingDisabled

func (a *Auth) IsLoggingDisabled() (bool, error)

func (*Auth) IsRegistrationOpen

func (a *Auth) IsRegistrationOpen() (bool, error)

func (*Auth) IsTurnEnabled

func (a *Auth) IsTurnEnabled() (bool, error)

func (*Auth) ListUsers

func (a *Auth) ListUsers() ([]string, error)

func (*Auth) Lookup

func (a *Auth) Lookup(ctx context.Context, username string) (string, bool, error)

func (*Auth) Name

func (a *Auth) Name() string

func (*Auth) SetJitRegistrationEnabled added in v0.10.0

func (a *Auth) SetJitRegistrationEnabled(enabled bool) error

func (*Auth) SetLoggingDisabled

func (a *Auth) SetLoggingDisabled(disabled bool) error

func (*Auth) SetRegistrationOpen

func (a *Auth) SetRegistrationOpen(open bool) error

func (*Auth) SetSetting added in v0.15.0

func (a *Auth) SetSetting(key, value string) error

SetSetting stores a raw string value in the settings table.

func (*Auth) SetTurnEnabled

func (a *Auth) SetTurnEnabled(enabled bool) error

func (*Auth) SetUserPassword

func (a *Auth) SetUserPassword(username, password string) error

type FuncHashCompute

type FuncHashCompute func(opts HashOpts, pass string) (string, error)

type FuncHashVerify

type FuncHashVerify func(pass, hashSalt string) error

type HashOpts

type HashOpts struct {
	// Bcrypt cost value to use. Should be at least 10.
	BcryptCost int

	Argon2Time    uint32
	Argon2Memory  uint32
	Argon2Threads uint8
}

HashOpts is the structure that holds additional parameters for used hash functions. They are used for new passwords.

These parameters should be stored together with the hashed password so it can be verified independently of the used HashOpts.

Jump to

Keyboard shortcuts

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