fileuser

package
v1.30.3 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2026 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package fileuser provides a file-based implementation of the UserStore interface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*Store)

Option is a functional option for configuring the Store.

type Store

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

Store implements auth.UserStore using the local filesystem. Users are stored as individual JSON files in the configured directory. Thread-safe through internal locking.

func New

func New(baseDir string, opts ...Option) (*Store, error)

New creates a new file-based user store. New creates a file-backed Store that persists users as per-user JSON files in baseDir. The baseDir must be non-empty; provided Option functions are applied to the store. If baseDir does not exist it is created with directory permissions 0750, and an initial in-memory index is built from existing user files. Returns an error on invalid input, failure to create the directory, or failure to build the initial index.

func (*Store) Count

func (s *Store) Count(_ context.Context) (int64, error)

Count returns the total number of users.

func (*Store) Create

func (s *Store) Create(_ context.Context, user *auth.User) error

Create stores a new user.

func (*Store) Delete

func (s *Store) Delete(_ context.Context, id string) error

Delete removes a user by their ID.

func (*Store) GetByID

func (s *Store) GetByID(_ context.Context, id string) (*auth.User, error)

GetByID retrieves a user by their unique ID.

func (*Store) GetByUsername

func (s *Store) GetByUsername(ctx context.Context, username string) (*auth.User, error)

GetByUsername retrieves a user by their username.

func (*Store) List

func (s *Store) List(ctx context.Context) ([]*auth.User, error)

List returns all users in the store.

func (*Store) Update

func (s *Store) Update(_ context.Context, user *auth.User) error

Update modifies an existing user.

Jump to

Keyboard shortcuts

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