auth

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package auth implements signing in: checking credentials, starting and ending sessions, and creating the first account.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dependencies

type Dependencies struct {
	Users      resource.UserStore
	Sessions   resource.SessionStore
	Hasher     resource.PasswordHasher
	Logger     *slog.Logger
	SessionTTL time.Duration
	Now        func() time.Time // defaults to time.Now
}

Dependencies are what the auth service needs.

type Service

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

Service implements service.Auth.

func NewService

func NewService(d Dependencies) (*Service, error)

NewService returns an auth service. It hashes a random decoy password once.

func (*Service) Authenticate

func (s *Service) Authenticate(ctx context.Context, token string) (domain.User, error)

Authenticate implements service.Auth.

func (*Service) BootstrapAdmin

func (s *Service) BootstrapAdmin(ctx context.Context, email, password string) (bool, error)

BootstrapAdmin implements service.Auth.

func (*Service) Login

func (s *Service) Login(ctx context.Context, email, password string) (service.AuthSession, error)

Login implements service.Auth.

func (*Service) Logout

func (s *Service) Logout(ctx context.Context, token string) error

Logout implements service.Auth.

Jump to

Keyboard shortcuts

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