auth

package
v1.13.1 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2026 License: GPL-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SessionName = "qui_user_session"
)

Variables

View Source
var (
	ErrInvalidCredentials = errors.New("invalid username or password")
	ErrNotSetup           = errors.New("initial setup required")
)

Functions

func HashPassword

func HashPassword(password string) (string, error)

HashPassword generates an Argon2id hash of the password

func VerifyPassword

func VerifyPassword(password, encodedHash string) (bool, error)

VerifyPassword verifies a password against an Argon2id hash

Types

type Argon2Params

type Argon2Params struct {
	Memory      uint32
	Iterations  uint32
	Parallelism uint8
	SaltLength  uint32
	KeyLength   uint32
}

Argon2 parameters - these are secure defaults

func DefaultArgon2Params

func DefaultArgon2Params() *Argon2Params

DefaultArgon2Params returns secure default parameters for Argon2id

type Service

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

func NewService

func NewService(db dbinterface.Querier) *Service

func (*Service) ChangePassword

func (s *Service) ChangePassword(ctx context.Context, oldPassword, newPassword string) error

ChangePassword updates the user's password

func (*Service) CreateAPIKey

func (s *Service) CreateAPIKey(ctx context.Context, name string) (string, *models.APIKey, error)

CreateAPIKey generates a new API key

func (*Service) DeleteAPIKey

func (s *Service) DeleteAPIKey(ctx context.Context, id int) error

DeleteAPIKey removes an API key

func (*Service) IsSetupComplete

func (s *Service) IsSetupComplete(ctx context.Context) (bool, error)

IsSetupComplete checks if initial setup has been completed

func (*Service) ListAPIKeys

func (s *Service) ListAPIKeys(ctx context.Context) ([]*models.APIKey, error)

ListAPIKeys returns all API keys

func (*Service) Login

func (s *Service) Login(ctx context.Context, username, password string) (*models.User, error)

Login validates credentials and returns the user

func (*Service) SetupUser

func (s *Service) SetupUser(ctx context.Context, username, password string) (*models.User, error)

SetupUser creates the initial user account

func (*Service) ValidateAPIKey

func (s *Service) ValidateAPIKey(ctx context.Context, key string) (*models.APIKey, error)

ValidateAPIKey checks if an API key is valid

Jump to

Keyboard shortcuts

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