diff --git a/go.mod b/go.mod index bacf791..0d96a40 100644 --- a/go.mod +++ b/go.mod @@ -14,6 +14,7 @@ require ( github.com/minio/minio-go/v7 v7.0.0 github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 + github.com/sethvargo/go-password/password ) require ( diff --git a/utils.go b/utils.go index c8a9771..9d1206c 100644 --- a/utils.go +++ b/utils.go @@ -7,7 +7,7 @@ import ( "github.com/go-ldap/ldap/v3" // "bytes" // "crypto/rand" - "encoding/binary" + // "encoding/hex" // "fmt" // "html/template" @@ -19,6 +19,7 @@ import ( // "github.com/emersion/go-smtp" // "github.com/gorilla/mux" // "golang.org/x/crypto/argon2" + "github.com/sethvargo/go-password/password" ) type NewUser struct { @@ -43,9 +44,12 @@ func openLdap(config ConfigFile) *ldap.Conn { } } -func suggestPassword() uint32 { - random := make([]byte, 32) - return binary.BigEndian.Uint32(random[0:12]) +func suggestPassword() string { + res, err := password.Generate(10, 2, 2, false, false) + if err != nil { + log.Fatal(err) + } + return res } func addNewUser(newUser NewUser, config *ConfigFile, login *LoginStatus) bool {