gnunet-svn
[Top][All Lists]
Advanced

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

[taler-taldir] branch master updated: Switch to postgres


From: gnunet
Subject: [taler-taldir] branch master updated: Switch to postgres
Date: Tue, 19 Apr 2022 17:15:24 +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 7c7ea95  Switch to postgres
7c7ea95 is described below

commit 7c7ea95a9fb12362d704e98499cb894b7919a87d
Author: Martin Schanzenbach <mschanzenbach@posteo.de>
AuthorDate: Tue Apr 19 17:15:06 2022 +0200

    Switch to postgres
---
 config.json | 10 +++++++---
 go.mod      | 14 ++++++++++----
 taldir.go   | 19 +++++++++++++------
 3 files changed, 30 insertions(+), 13 deletions(-)

diff --git a/config.json b/config.json
index 9e0d381..a03be20 100644
--- a/config.json
+++ b/config.json
@@ -1,9 +1,13 @@
 {
   "production": false,
-  "db_backend": "sqlite",
   "validators": ["email","phone"],
   "email_sender": "taldir@taler.net",
   "host": "https://taldir.net/";,
-  "bind_to": "localhost:10000",
-  "salt": "ChangeMe" 
+  "bind_to": "localhost:11000",
+  "salt": "ChangeMe",
+  "pq_host": "localhost",
+  "pq_port": 5432,
+  "pq_user": "taldir",
+  "pq_password": "secret",
+  "pq_dbname": "taldir"
 }
diff --git a/go.mod b/go.mod
index d4da52f..0a2a8bc 100644
--- a/go.mod
+++ b/go.mod
@@ -3,10 +3,16 @@ module taler.net/taldir
 go 1.16
 
 require (
-       github.com/gorilla/mux v1.8.0 // indirect
+       github.com/alexbrainman/sspi v0.0.0-20180613141037-e580b900e9f5 // 
indirect
+       github.com/gorilla/mux v1.8.0
+       github.com/jcmturner/gokrb5/v8 v8.2.0 // indirect
        github.com/jinzhu/now v1.1.5 // indirect
-       github.com/mattn/go-sqlite3 v1.14.12 // indirect
        golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 // indirect
-       gorm.io/driver/sqlite v1.3.1 // indirect
-       gorm.io/gorm v1.23.4 // indirect
+       gopkg.in/jcmturner/aescts.v1 v1.0.1 // indirect
+       gopkg.in/jcmturner/dnsutils.v1 v1.0.1 // indirect
+       gopkg.in/jcmturner/goidentity.v3 v3.0.0 // indirect
+       gopkg.in/jcmturner/gokrb5.v7 v7.5.0 // indirect
+       gopkg.in/jcmturner/rpc.v1 v1.1.0 // indirect
+       gorm.io/driver/postgres v1.3.4
+       gorm.io/gorm v1.23.4
 )
diff --git a/taldir.go b/taldir.go
index b4c4eaf..eeb622e 100644
--- a/taldir.go
+++ b/taldir.go
@@ -8,26 +8,29 @@ import (
   "encoding/json"
   "github.com/gorilla/mux"
   "gorm.io/gorm"
-  "gorm.io/driver/sqlite"
   "encoding/base32"
   "math/rand"
   "net/smtp"
-  "golang.org/x/crypto/argon2"
   "crypto/sha256"
+  "gorm.io/driver/postgres"
 )
 
 type Configuration struct {
   Production    bool
-  DbBackend     string `json:"db_backend"`
   Validators   []string
   EmailSender string `json:"email_sender"`
   Salt string `json:"salt"`
   Host string `json:"host"`
   BindTo string `json:"bind_to"`
+  PqUser string `json:"pq_user"`
+  PqPassword string `json:"pq_pw"`
+  PqHost string `json:"pq_host"`
+  PqPort int `json:"pq_port"`
+  PqDbname string `json:"pq_dbname"`
 }
 
 // A mappind entry from the identity key hash to a wallet key
-// The identity key hash is argon2(sha256(identity)) where identity is
+// The identity key hash is sha256(sha256(identity)|salt) where identity is
 // one of the identity key types supported (e.g. email)
 type Entry struct {
   gorm.Model
@@ -99,7 +102,10 @@ func returnSingleEntry(w http.ResponseWriter, r 
*http.Request){
 func hashIdentityKey(idkey string) string {
   fmt.Println("Using salt " + config.Salt)
   salt := make([]byte, len(config.Salt))
-  return base32.StdEncoding.EncodeToString(argon2.IDKey([]byte(idkey), salt, 
1, 64*1024, 4, 32))
+  h := sha256.New()
+  h.Write([]byte(idkey))
+  h.Write(salt)
+  return base32.StdEncoding.EncodeToString(h.Sum(nil))
 }
 
 // Called by the registrant to validate the registration request. The 
reference ID was
@@ -220,7 +226,8 @@ func main() {
   for _, a := range config.Validators {
     validators[a] = true
   }
-  _db, err := gorm.Open(sqlite.Open("./taldir.db"), &gorm.Config{})
+  psqlconn := fmt.Sprintf("host=%s port=%d user=%s password=%s dbname=%s 
sslmode=disable", config.PqHost, config.PqPort, config.PqUser, 
config.PqPassword, config.PqDbname) 
+  _db, err := gorm.Open(postgres.Open(psqlconn), &gorm.Config{})
   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]