user

package
v0.0.0-...-0227cab Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultUserName from reids 6.0, there is a default user named "default"
	// for compatibility, the default user set as RoleDeveloper
	DefaultUserName         = "default"
	DefaultOperatorUserName = "operator"

	// password secret key name
	PasswordSecretKey = "password"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Password

type Password struct {
	SecretName string `json:"secretName,omitempty"`
	// contains filtered or unexported fields
}

Password

func NewPassword

func NewPassword(secret *v1.Secret) (*Password, error)

NewPassword

func (*Password) GetSecretName

func (p *Password) GetSecretName() string

func (*Password) Secret

func (p *Password) Secret() *v1.Secret

func (*Password) SetSecret

func (p *Password) SetSecret(secret *v1.Secret) error

func (*Password) String

func (p *Password) String() string

String return password in plaintext

type Rule

type Rule struct {
	// Categories
	Categories           []string `json:"categories,omitempty"`
	DisallowedCategories []string `json:"disallowedCategories,omitempty"`
	// AllowedCommands supports <command> and <command>|<subcommand>
	AllowedCommands []string `json:"allowedCommands,omitempty"`
	// DisallowedCommands supports <command> and <command>|<subcommand>
	DisallowedCommands []string `json:"disallowedCommands,omitempty"`
	// KeyPatterns support multi patterns, for 7.0 support %R~ and %W~ patterns
	KeyPatterns []string `json:"keyPatterns,omitempty"`
	Channels    []string `json:"channels,omitempty"`
}

Rule acl rules

This rule supports redis 7.0, which is compatable with 6.0

func (*Rule) Parse

func (r *Rule) Parse(ruleString string) error

func (*Rule) String

func (r *Rule) String() string

func (*Rule) Validate

func (r *Rule) Validate() error

type User

type User struct {
	Name     string    `json:"name"`
	Role     UserRole  `json:"role"`
	Password *Password `json:"password,omitempty"`
	Rules    []*Rule   `json:"rules,omitempty"`
}

User

func NewOperatorUser

func NewOperatorUser(secret *v1.Secret, ACL2Support bool) (*User, error)

NewOperatorUser

func NewUser

func NewUser(name string, role UserRole, secret *v1.Secret) (*User, error)

NewUser

func NewUserFromRedisUser

func NewUserFromRedisUser(username, ruleStr string, password_obj *Password) (*User, error)

func (*User) AppendRule

func (u *User) AppendRule(rules ...*Rule) error

AppendRule

func (*User) GetPassword

func (u *User) GetPassword() *Password

func (*User) String

func (u *User) String() string

String

func (*User) Validate

func (u *User) Validate() error

type UserRole

type UserRole string

UserRole

const (
	RoleOperator  UserRole = "Operator"
	RoleDeveloper UserRole = "Developer"
)

Jump to

Keyboard shortcuts

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