commit 8747e81b337f21559e3137bee412e9b9cea1ac8c
parent cb3e901f691250fa4fbadf9e5edcbe4722c92812
Author: Martin Schanzenbach <schanzen@gnunet.org>
Date: Thu, 7 Jul 2022 18:19:05 +0200
activation code 16 bytes; configurable
Diffstat:
3 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/cmd/taldir-server/taldir.go b/cmd/taldir-server/taldir.go
@@ -377,7 +377,8 @@ func (t *Taldir) registerRequest(w http.ResponseWriter, r *http.Request){
}
}
err = t.Db.First(&validation, "h_address = ?", validation.HAddress).Error
- validation.Code = util.GenerateCode()
+ bytes := t.Cfg.Section("taldir").Key("activation_code_bytes").MustInt(16)
+ validation.Code = util.GenerateCode(bytes)
validation.Inbox = req.Inbox
validation.Duration = req.Duration
validation.PublicKey = req.PublicKey
diff --git a/taldir.conf b/taldir.conf
@@ -10,6 +10,7 @@ default_doc_filetype = text/markdown
default_doc_lang = en-US
default_tos_path = terms/
default_pp_path = privacy/
+activation_code_bytes = 16
[taldir-email]
sender = "taldir@taler.net"
diff --git a/util/helper.go b/util/helper.go
@@ -40,8 +40,8 @@ func GenerateSolution(pubkeyEncoded string, code string) string {
}
// Generates random reference token used in the validation flow.
-func GenerateCode() string {
- randBytes := make([]byte, 32)
+func GenerateCode(bytes int) string {
+ randBytes := make([]byte, bytes)
_, err := rand.Read(randBytes)
if err != nil {
panic(err)