5 "golang.org/x/crypto/bcrypt"
8 const GuestAccount = "guest" // default account used when no login is provided for a connection
11 Login string `yaml:"Login"`
12 Name string `yaml:"Name"`
13 Password string `yaml:"Password"`
14 Access accessBitmap `yaml:"Access"`
17 // Read implements io.Reader interface for Account
18 func (a *Account) Read(p []byte) (n int, err error) {
20 NewField(fieldUserName, []byte(a.Name)),
21 NewField(fieldUserLogin, negateString([]byte(a.Login))),
22 NewField(fieldUserAccess, a.Access[:]),
25 if bcrypt.CompareHashAndPassword([]byte(a.Password), []byte("")) != nil {
26 fields = append(fields, NewField(fieldUserPassword, []byte("x")))
29 fieldCount := make([]byte, 2)
30 binary.BigEndian.PutUint16(fieldCount, uint16(len(fields)))
32 p = append(p, fieldCount...)
34 for _, field := range fields {
35 p = append(p, field.Payload()...)