Help us shape the future of Go! Take the 2026 Go Developer Survey

redisacl

package
v1.3.15 Latest Latest
Warning

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

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

Documentation

Overview

Package redisacl renders the fleet store's ACL users from the function library a build embeds and the key families its tools use, and compares a rendering with a store's live ACL. It is what `nova-redis acl` runs and what fleet/redis.yml converges a store with (docs/FLEET.md, "The store's ACL").

A role is declared once, here: its user, the key families it reads or writes, the command categories it holds and the library files whose functions it may call. The function names are never listed: they are read out of the library (redisfn.Library.Registered) at render time, FCALL for each and FCALL_RO for each the library flags no-writes, so a function added to a file reaches every role of that file at the next render, and a file added to the library is refused until a role names it or it is declared the coordinator's alone (TestEveryLibraryFileHasItsRoles).

Index

Constants

View Source
const (
	Coordinator = "coordinator"
	Member      = "member"
	Table       = "table"
	Friend      = "friend"
)

The roles, by the name the CLI prints.

View Source
const MaxShown = 8

MaxShown bounds each list a drift line prints; the count of the rest follows.

Variables

View Source
var CoordinatorOnly = []string{"lua/capacity.lua", "lua/friend_roles.lua"}

CoordinatorOnly are the library files no role but the coordinator calls: nova-config's apply writes the capacity and the friends' roles through them.

View Source
var Families = []Family{
	{"tables", []string{"table:*", "tables"}, "pkg/ntable DefKey, ChangesKey, RowsKeyAt, Registry"},
	{"views", []string{"view:*", "views"}, "pkg/ntable: a view's key and the views registry"},
	{"sprint", []string{"sprint:*"}, "internal/sprint Names.Key: the epoch, the beats, the tick's keys"},
	{"machines", []string{"machine:*", "machines"}, "pkg/config MachineKey, MachineCeilingKey, MachinesKey"},
	{"beats", []string{"bench:*"}, "pkg/config BeatKey: a machine's measured facts"},
	{"friends", []string{"friend:*", "friends", "friends:*"}, "pkg/config FriendBeatKey, FriendsKey: a friend's beat, desired slots, width, mode and roles"},
	{"fleet", []string{"fleet:*"}, "pkg/config FleetKey"},
	{"loops", []string{"loops", "loop:*"}, "pkg/config LoopsKey, LoopKey"},
	{"providers", []string{"providers", "provider:*"}, "pkg/config ProvidersKey, ProviderKey"},
	{"routes", []string{"routes", "route:*"}, "pkg/config RoutesKey, RouteKey"},
	{"config", []string{"config:decl"}, "pkg/config DeclKey"},
	{"tokens", []string{"tokens:ledger:*"}, "internal/record LedgerPrefix: nova-tokens ledger and report, logged in as the seat's user"},
	{"events", []string{"ev:github"}, "internal/ghevent/wire Stream: the CI run receipt (nova-ci github receipt, tools/ci/reportrun.go) XADDs it as the bench user"},
}

Families are the key families of the fleet store, each held to its owner's key functions by TestFamiliesAreTheOwnersKeys. A key a table cell is bound to (a binding may name any key outside table:) is in none of them unless it falls in one: only the coordinator reads such a key.

Functions

func LuaCommands

func LuaCommands(lib redisfn.Library) (map[string][]string, error)

LuaCommands is the commands each file of the library names, by the file's name as the glob matches it.

Types

type Catalog

type Catalog map[string][]string

Catalog is each command category and its commands, as ACL CAT prints them, read from the store a rendering is compared with: the categories mean what that store's version says they mean.

func (Catalog) Commands

func (c Catalog) Commands(rules []string) map[string]bool

Commands expands command rules applied in order into the commands they allow: +@<category> and -@<category> by the catalog, +@all (allcommands) and -@all (nocommands) over every category, +<command> and +<command>|<sub> as named, -<command> with every subcommand of it. Rules that are not command rules are skipped.

type Drift

type Drift struct {
	Missing, Off, Selectors  bool
	KeysAdd, KeysDel         []string
	ChannelsAdd, ChannelsDel []string
	CommandsAdd, CommandsDel []string
}

Drift is how a live user differs from its rendering; zero is none.

func Compare

func Compare(want User, live Live, cat Catalog) Drift

Compare is the drift of a live user from its rendering, the commands compared as the sets the catalog expands both to, so a store that prints the same permissions in other words is no drift.

func (Drift) Fields

func (d Drift) Fields() string

Fields is the drift as key=value fields for one line: what the apply would add (+=) and remove (-=), each list bounded by MaxShown.

func (Drift) None

func (d Drift) None() bool

None reports whether the live user is the rendering.

type Family

type Family struct {
	Name     string
	Patterns []string
	From     string
}

Family is one family of keys the tools use, with the code that names them; render prints each with its source (ACL FAMILY lines).

type Live

type Live struct {
	Exists bool
	On     bool
	// NoPass is the nopass flag: the user logs in with any password.
	NoPass bool
	// Keys, Channels and Commands are the reply's fields as the store
	// prints them; Selectors counts the user's selectors.
	Keys, Channels, Commands string
	Selectors                int
}

Live is what a store's ACL GETUSER says of one user: never its passwords.

type Role

type Role struct {
	// Name is the role; User the ACL user that holds it.
	Name, User string
	// Keys are the key rules: ~<pattern> to read and write, %R~<pattern> to
	// read.
	Keys []string
	// Commands are the command rules before the functions.
	Commands []string
	// Files are the library files whose functions it may call; every file
	// when All.
	Files []string
	All   bool
	// ReadOnly grants only the no-writes functions, through FCALL_RO.
	ReadOnly bool
	// Extra are command rules after the functions.
	Extra []string
}

Role is one ACL user's declaration.

func Roles

func Roles() []Role

Roles are the four roles, in the order they render. The users are the tools' own defaults: the member's is the bench user every member loop logs in as (redisauth.NoUserHint), the table reader's and the friend's the ns- users the tools already name.

type User

type User struct {
	Role, Name string
	Rules      []string
	// Functions is how many library functions it may call.
	Functions int
}

User is one rendered ACL user: the arguments of ACL SETUSER after its name. A rendering never touches a password.

func Render

func Render(lib redisfn.Library) ([]User, error)

Render is every role's user for the library. A role naming a file the library does not have is refused: a renamed file must not leave a role silently without its functions.

func (User) Line

func (u User) Line() string

Line is the user as a pasteable ACL SETUSER command.

Jump to

Keyboard shortcuts

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