[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-taldir] branch master updated: add stub twitter validator
From: |
gnunet |
Subject: |
[taler-taldir] branch master updated: add stub twitter validator |
Date: |
Wed, 06 Jul 2022 16:14:50 +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 820f168 add stub twitter validator
820f168 is described below
commit 820f168bebb3c112782ecd086022fb2d8f1df3b7
Author: Martin Schanzenbach <schanzen@gnunet.org>
AuthorDate: Wed Jul 6 16:14:48 2022 +0200
add stub twitter validator
---
validate_test.sh => taldir-validate-test.sh | 0
taldir-validate-twitter.sh | 12 ++++++
taldir.conf | 6 ++-
taldir.go | 66 ++++++++++++++++++++++++++---
4 files changed, 76 insertions(+), 8 deletions(-)
diff --git a/validate_test.sh b/taldir-validate-test.sh
similarity index 100%
rename from validate_test.sh
rename to taldir-validate-test.sh
diff --git a/taldir-validate-twitter.sh b/taldir-validate-twitter.sh
new file mode 100755
index 0000000..e600d9f
--- /dev/null
+++ b/taldir-validate-twitter.sh
@@ -0,0 +1,12 @@
+#!/bin/bash
+#
+# IMPORTANT: Before this can be used, as the taldir service user
+# you need to authorize this CLI app for the taldir twitter account.
+# e.g.:
+# $ t authorize
+#
+TWITTER_USER=$1
+CODE=$2
+LINK=$(./taldir -l -a $1 -c $2)
+MESSAGE="Follow this link to complete your Taldir registration: $LINK"
+t dm $TWITTER_USER $MESSAGE
diff --git a/taldir.conf b/taldir.conf
index e49c25a..5116801 100644
--- a/taldir.conf
+++ b/taldir.conf
@@ -18,7 +18,11 @@ command = validate_phone.sh
[taldir-test]
challenge_fee = 23 Kudos
-command = ./validate_test.sh
+command = ./taldir-validate-test.sh
+
+[taldir-twitter]
+challenge_fee = 2 Kudos
+command = ./taldir-validate-twitter.sh
[taldir-pq]
host = "localhost"
diff --git a/taldir.go b/taldir.go
index 38f1608..fda7e30 100644
--- a/taldir.go
+++ b/taldir.go
@@ -1,5 +1,13 @@
package main
+/* TODO
+ - ToS API (terms, privacy) with localizations
+ - Prettify QR code landing page
+ - Base32: Use gnunet-go module? (currently copied)
+ - OrderId processing
+ - Maintenance of database: When to delete expired validations?
+*/
+
import (
"os"
"os/exec"
@@ -41,6 +49,7 @@ type VersionResponse struct {
}
type Method struct {
+
// Name of the method, e.g. "email" or "sms".
Name string `json:"name"`
@@ -54,7 +63,7 @@ type RateLimitedResponse struct {
// Taler error code, TALER_EC_TALDIR_REGISTER_RATE_LIMITED.
Code int `json:"code"`
- // At what frequency are new registrations allowed. FIXME: In what?
+ // At what frequency are new registrations allowed. FIXME: In what?
Currently: In microseconds
RequestFrequency int64 `json:"request_frequency"`
// The human readable error message.
@@ -85,11 +94,23 @@ type RegisterMessage struct {
// 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 {
+
+ // ORM
gorm.Model `json:"-"`
+
+ // The salted hash (SHA512) of the hashed address (h_address)
HsAddress string `json:"-"`
+
+ // (HTTPS) endpoint URL for the inbox service for this address
Inbox string `json:"inbox_url"`
+
+ // Public key of the user to register in base32
PublicKey string `json:"public_key"`
+
+ // Time of (re)registration. In Unix epoch microseconds)
RegisteredAt int64 `json:"-"`
+
+ // How long the registration lasts in microseconds
Duration int64 `json:"-"`
}
@@ -98,12 +119,23 @@ type Entry struct {
// validation reference. The validation reference is sent to the identity
// depending on the out-of-band chennel defined through the identity key type.
type Validation struct {
+
+ // ORM
gorm.Model `json:"-"`
+
+ // The hash (SHA512) of the address
HAddress string `json:"h_address"`
- Method string `json:"method"`
+
+ // For how long should the registration last
Duration int64 `json:"duration"`
+
+ // (HTTPS) endpoint URL for the inbox service for this address
Inbox string `json:"inbox_url"`
+
+ // The activation code sent to the client
Code string `json:"activation_code"`
+
+ // Public key of the user to register
PublicKey string `json:"public_key"`
}
@@ -230,7 +262,6 @@ func validationRequest(w http.ResponseWriter, r
*http.Request){
w.WriteHeader(http.StatusInternalServerError)
return
}
- // FIXME are we still doing this??
entry.HsAddress = saltHAddress(validation.HAddress)
entry.Inbox = validation.Inbox
entry.Duration = validation.Duration
@@ -321,8 +352,8 @@ func registerRequest(w http.ResponseWriter, r
*http.Request){
}
err = db.First(&validation, "h_address = ?", validation.HAddress).Error
if err == nil {
- // Validation already pending for this address
- db.Delete(&validation) // FIXME for debugging only
+ // FIXME: Validation already pending for this address
+ // How should we proceed here? Expire old validations?
w.WriteHeader(202)
return
} else {
@@ -338,8 +369,6 @@ func registerRequest(w http.ResponseWriter, r
*http.Request){
}
fmt.Println("Address registration request created:", validation)
}
- // FIXME: Here we should call the validator shell script with the
- // parsed parameters to initiate the validation.
if !cfg.Section("taldir-" + vars["method"]).HasKey("command") {
log.Fatal(err)
db.Delete(&validation)
@@ -404,6 +433,14 @@ func validationPage(w http.ResponseWriter, r
*http.Request) {
return
}
+// Generates a link from a code and address
+func generateLink(addr string, code string) string {
+ h := sha512.New()
+ h.Write([]byte(addr))
+ h_addr := util.EncodeBinaryToString(h.Sum(nil))
+ return "taler://taldir/" + h_addr + "/" + code + "-wallet"
+}
+
// Generates a solution from a code and pubkey
func generateSolution(pubkeyEncoded string, code string) string {
pubkey, err := util.DecodeStringToBinary(pubkeyEncoded, 36)
@@ -451,8 +488,10 @@ func main() {
fmt.Println("Production mode enabled")
}
var solveFlag = flag.Bool("s", false, "Provide a solution for the
code/pubkey")
+ var linkFlag = flag.Bool("l", false, "Provide a link for activation")
var codeFlag = flag.String("c", "", "Activation code")
var pubkeyFlag = flag.String("p", "", "Public key")
+ var addressFlag = flag.String("a", "", "Address")
var dropFlag = flag.Bool("D", false, "Drop all data in table (DANGEROUS!)")
flag.Parse()
if *solveFlag {
@@ -467,6 +506,19 @@ func main() {
for _, a := range
strings.Split(cfg.Section("taldir").Key("validators").String(), " ") {
validators[a] = true
}
+ if *linkFlag {
+ if len(*codeFlag) == 0 || len(*addressFlag) == 0 {
+ fmt.Println("You need to provide an activation code and an address to
generate a link")
+ os.Exit(1)
+ }
+ fmt.Println(generateLink(*addressFlag, *codeFlag))
+ os.Exit(0)
+ }
+ validators = make(map[string]bool)
+ for _, a := range
strings.Split(cfg.Section("taldir").Key("validators").String(), " ") {
+ validators[a] = true
+ }
+
psqlconn := fmt.Sprintf("host=%s port=%d user=%s password=%s dbname=%s
sslmode=disable",
cfg.Section("taldir-pq").Key("host").MustString("localhost"),
cfg.Section("taldir-pq").Key("port").MustInt64(5432),
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-taldir] branch master updated: add stub twitter validator,
gnunet <=