Versions in this module Expand all Collapse all v1 v1.0.0 Jan 8, 2024 Changes in this version + func CreateMiddleware(service Service) func(next http.Handler) http.Handler + func GetUser(r *http.Request) *models.User + func RequiredMiddleware(next http.Handler) http.Handler + type Auth struct + func New(repository Repository, conf *config.Config, log *slog.Logger) *Auth + func (a *Auth) Authenticate(ctx context.Context, username, password string) (*models.User, error) + func (a *Auth) CreateSession(user *models.User) (*models.Session, error) + func (a *Auth) CreateUser(ctx context.Context, username, password string) (*models.User, error) + func (a *Auth) Mount(router chi.Router) + func (a *Auth) ValidateSession(session *models.Session) error + type Repository interface + GetByUsername func(ctx context.Context, username string) (*models.UserCredentials, error) + Insert func(ctx context.Context, username, password, salt string) (*models.UserCredentials, error) + type RepositoryImpl struct + func NewRepository(db *sqlx.DB) *RepositoryImpl + func (r *RepositoryImpl) GetByUsername(ctx context.Context, username string) (*models.UserCredentials, error) + func (r *RepositoryImpl) Insert(ctx context.Context, username, password, salt string) (*models.UserCredentials, error) + type Service interface + ValidateSession func(session *models.Session) error