auth

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: MIT Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package auth manages users and passwords (AUTH, requirepass) and per-user permissions (ACL). See acl.go for the rule language.

Index

Constants

View Source
const DefaultUser = "default"

Variables

View Source
var (
	ErrWrongPass  = errors.New("WRONGPASS invalid username-password pair or user is disabled.")
	ErrNoSuchUser = errors.New("ERR no such user")
)

Functions

This section is empty.

Types

type Store

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

Store holds all users. Users are copy-on-write so readers never see a half-updated user.

func New

func New(requirepass string) *Store

New creates the store with a "default" user that has every permission and either no password or requirepass.

func (*Store) Authenticate

func (s *Store) Authenticate(name, pass string) error

Authenticate checks a username/password pair.

func (*Store) AutoLogin

func (s *Store) AutoLogin() bool

AutoLogin reports whether new connections are authenticated as "default" without AUTH (true when the default user has no password).

func (*Store) Check

func (s *Store) Check(user, command string, categories []string, keys []string) error

Check returns an error if user may not run command (with its categories) on the given keys.

func (*Store) DelUser

func (s *Store) DelUser(name string) bool

func (*Store) Describe

func (s *Store) Describe(name string) (string, bool)

Describe returns the user's rules in ACL LIST format.

func (*Store) SetDefaultPassword

func (s *Store) SetDefaultPassword(pass string)

SetDefaultPassword is used by requirepass / CONFIG SET requirepass.

func (*Store) SetUser

func (s *Store) SetUser(name string, rules []string) error

SetUser creates or modifies a user with ACL rules, e.g.

ACL SETUSER alice on >secret ~cache:* +@read +set -flushall

Rules: on, off, >pass, <pass, nopass, resetpass, ~pattern, allkeys, resetkeys, +cmd, -cmd, +@category, -@category, allcommands (+@all), nocommands (-@all), reset.

func (*Store) User

func (s *Store) User(name string) (*User, bool)

User returns the current version of a user.

func (*Store) Users

func (s *Store) Users() []string

Users returns user names, sorted.

type User

type User struct {
	Name    string
	Enabled bool
	NoPass  bool

	AllCommands bool

	AllKeys     bool
	KeyPatterns []string
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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