diff options
Diffstat (limited to 'write.go')
-rw-r--r-- | write.go | 23 |
1 files changed, 21 insertions, 2 deletions
@@ -7,8 +7,9 @@ import ( ldap "bottin/ldapserver" - consul "github.com/hashicorp/consul/api" message "bottin/goldap" + + consul "github.com/hashicorp/consul/api" ) // Generic item modification function -------- @@ -38,7 +39,7 @@ func (server *Server) putAttributes(dn string, attrs Entry) error { // Retreieve previously existing attributes, which we will use to delete // entries with the wrong case - previous_pairs, _, err := server.kv.List(prefix + "/attribute=", &server.readOpts) + previous_pairs, _, err := server.kv.List(prefix+"/attribute=", &server.readOpts) if err != nil { return err } @@ -65,6 +66,24 @@ func (server *Server) putAttributes(dn string, attrs Entry) error { } } + // if the password is not yet hashed we hash it + if k == ATTR_USERPASSWORD { + tmpValues := []string{} + for _, pw := range values { + _, err := determineHashType(pw) + if err != nil { + encodedPassword, err := SSHAEncode(pw) + if err != nil { + return err + } + tmpValues = append(tmpValues, encodedPassword) + } else { + tmpValues = append(tmpValues, pw) + } + } + values = tmpValues + } + // If we have zero values, delete associated k/v pair // Otherwise, write new values if len(values) == 0 { |