mirror of
https://github.com/eosswedenorg/thalos
synced 2026-07-04 12:03:41 +02:00
cmd/tools/redis-acl.go: fix correct syntax for cleartext passwords.
This commit is contained in:
parent
69b31eae1a
commit
72b4f0a327
1 changed files with 17 additions and 8 deletions
|
|
@ -26,6 +26,9 @@ type User struct {
|
||||||
|
|
||||||
// True if password was generated, false if not.
|
// True if password was generated, false if not.
|
||||||
Generated bool
|
Generated bool
|
||||||
|
|
||||||
|
// True if password should be hashed, false otherwise.
|
||||||
|
Hash bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewUser(name, password string) User {
|
func NewUser(name, password string) User {
|
||||||
|
|
@ -34,13 +37,19 @@ func NewUser(name, password string) User {
|
||||||
Name: name,
|
Name: name,
|
||||||
Password: randomString(32),
|
Password: randomString(32),
|
||||||
Generated: true,
|
Generated: true,
|
||||||
|
Hash: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return User{Name: name, Password: password}
|
return User{Name: name, Password: password}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *User) Hash() {
|
func (u *User) GetPassword() string {
|
||||||
u.Password = "#" + hash(u.Password)
|
|
||||||
|
if u.Hash {
|
||||||
|
return "#" + hash(u.Password)
|
||||||
|
}
|
||||||
|
|
||||||
|
return ">" + u.Password
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u User) Print() {
|
func (u User) Print() {
|
||||||
|
|
@ -81,11 +90,11 @@ user {{.client}} on {{.clientpw}} resetchannels &{{.prefix}}::* -@all +subscribe
|
||||||
}
|
}
|
||||||
|
|
||||||
return tmpl.Execute(w, map[string]string{
|
return tmpl.Execute(w, map[string]string{
|
||||||
"defaultpw": defUser.Password,
|
"defaultpw": defUser.GetPassword(),
|
||||||
"client": clientUser.Name,
|
"client": clientUser.Name,
|
||||||
"clientpw": clientUser.Password,
|
"clientpw": clientUser.GetPassword(),
|
||||||
"server": serverUser.Name,
|
"server": serverUser.Name,
|
||||||
"serverpw": serverUser.Password,
|
"serverpw": serverUser.GetPassword(),
|
||||||
"prefix": prefix,
|
"prefix": prefix,
|
||||||
"timestamp": time.Now().Format(time.UnixDate),
|
"timestamp": time.Now().Format(time.UnixDate),
|
||||||
})
|
})
|
||||||
|
|
@ -123,9 +132,9 @@ var RedisACLCmd = &cobra.Command{
|
||||||
serverUser.PrintIfGeneratedPW()
|
serverUser.PrintIfGeneratedPW()
|
||||||
clientUser.PrintIfGeneratedPW()
|
clientUser.PrintIfGeneratedPW()
|
||||||
|
|
||||||
defaultUser.Hash()
|
defaultUser.Hash = true
|
||||||
serverUser.Hash()
|
serverUser.Hash = true
|
||||||
clientUser.Hash()
|
clientUser.Hash = true
|
||||||
}
|
}
|
||||||
|
|
||||||
filename, _ := cmd.Flags().GetString("file")
|
filename, _ := cmd.Flags().GetString("file")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue