user

package
v0.0.0-...-3430a5a Latest Latest
Warning

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

Go to latest
Published: Nov 26, 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
	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
	KeyPatterns []string `json:"keyPatterns,omitempty"`
	// KeyReadPatterns >= 7.0 support key read patterns
	KeyReadPatterns []string `json:"keyReadPatterns,omitempty"`
	// KeyWritePatterns >= 7.0 support key write patterns
	KeyWritePatterns []string `json:"keyWritePatterns,omitempty"`
	// Channels >= 7.0 support channel patterns
	Channels []string `json:"channels,omitempty"`
}

Rule acl rules

This rule supports redis 7.0, which is compatable with 6.0

func NewRule

func NewRule(val string) (*Rule, error)

NewRule

func PatchRedisClusterClientRequiredRules

func PatchRedisClusterClientRequiredRules(rule *Rule) *Rule

Patch redis cluster client required rules

func PatchRedisPubsubRules

func PatchRedisPubsubRules(rule *Rule) *Rule

func (*Rule) Encode

func (rule *Rule) Encode() string

func (*Rule) IsCommandEnabled

func (r *Rule) IsCommandEnabled(cmd string, cates []string) bool

func (*Rule) Validate

func (r *Rule) Validate(disableACL bool) 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 NewSentinelUser

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

NewSentinelUser

func NewUser

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

NewUser

func NewUserFromRedisUser

func NewUserFromRedisUser(username, ruleStr string, pwd *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