gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-taldir] branch master updated: activation code 16 bytes; configur


From: gnunet
Subject: [taler-taldir] branch master updated: activation code 16 bytes; configurable
Date: Thu, 07 Jul 2022 18:19:08 +0200

This is an automated email from the git hooks/post-receive script.

martin-schanzenbach pushed a commit to branch master
in repository taldir.

The following commit(s) were added to refs/heads/master by this push:
     new 8747e81  activation code 16 bytes; configurable
8747e81 is described below

commit 8747e81b337f21559e3137bee412e9b9cea1ac8c
Author: Martin Schanzenbach <schanzen@gnunet.org>
AuthorDate: Thu Jul 7 18:19:05 2022 +0200

    activation code 16 bytes; configurable
---
 cmd/taldir-server/taldir.go | 3 ++-
 taldir.conf                 | 1 +
 util/helper.go              | 4 ++--
 3 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/cmd/taldir-server/taldir.go b/cmd/taldir-server/taldir.go
index 0194ae8..74973be 100644
--- 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
index a8da76c..5bc8235 100644
--- 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
index 29dda62..e1b0b04 100644
--- 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)

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]