auth

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotConfigured     = errors.New("passphrase not configured")
	ErrInvalidPassword   = errors.New("invalid passphrase")
	ErrAlreadyConfigured = errors.New("passphrase already configured")
)

Functions

func Decrypt

func Decrypt(ciphertext []byte, key []byte) ([]byte, error)

func DeriveKey

func DeriveKey(passphrase string, salt []byte) []byte

func Encrypt

func Encrypt(plaintext []byte, key []byte) ([]byte, error)

func GenerateSalt

func GenerateSalt() ([]byte, error)

func HashPassphrase

func HashPassphrase(passphrase string, salt []byte) string

func IsAuthenticated

func IsAuthenticated(ctx context.Context) bool

func VerifyPassphrase

func VerifyPassphrase(passphrase string, salt []byte, storedHash string) bool

Types

type Service

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

func New

func New(db *database.DB, cfg *config.Config) *Service

func (*Service) CheckAuthentication

func (s *Service) CheckAuthentication(r *http.Request) bool

func (*Service) DecryptCredentials

func (s *Service) DecryptCredentials(ciphertext []byte) ([]byte, error)

func (*Service) EncryptCredentials

func (s *Service) EncryptCredentials(plaintext []byte) ([]byte, error)

func (*Service) IsConfigured

func (s *Service) IsConfigured() bool

func (*Service) Login

func (s *Service) Login(w http.ResponseWriter, passphrase string) error

func (*Service) Logout

func (s *Service) Logout(w http.ResponseWriter)

func (*Service) Middleware

func (s *Service) Middleware(next http.Handler) http.Handler

func (*Service) OnCredentialsReady

func (s *Service) OnCredentialsReady(callback func())

func (*Service) Setup

func (s *Service) Setup(passphrase string) error

func (*Service) Validate

func (s *Service) Validate(passphrase string) bool

Jump to

Keyboard shortcuts

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