taldir

Directory service to resolve wallet mailboxes by messenger addresses
Log | Files | Refs | Submodules | README | LICENSE

commit b2031d107f9d7776f1d67a451bb2ca8cb011defc
parent 6a33b0f80b09dd2f70baf447e08b7c73cf396e6e
Author: Martin Schanzenbach <schanzen@gnunet.org>
Date:   Tue, 12 Jul 2022 19:00:28 +0200

generated tos and pp integrated

Diffstat:
MREADME.md | 20++++++++++++++++++++
Mconfig/taldir-example.conf | 5+++--
Mpkg/rest/taldir.go | 31++++++++++++++++++-------------
Dterms/de-DE.md | 1-
4 files changed, 41 insertions(+), 16 deletions(-)

diff --git a/README.md b/README.md @@ -86,3 +86,23 @@ $ validator-test <address> <code> The first argument of the validator command is the address in a validation method-specific format. For example, the email validation expects an email address, the Twitter validator expects a Twitter handle, etc. The second argument is the activation code generated by Taldir and which is expected to be transferred using the validation method to the user. + +# Terms of Service and Privacy Policy + +You may edit the document templates under `contrib/pp` and `contrib/tos` +to your needs. +You can build the documents using: + +``` +$ make update-tos +$ make update-pp +``` + +And configure/copy the built localized documents into your configured +paths, e.g.: + +``` +$ cp -r contrib/tos/en terms/ +$ cp -r contrib/pp/en terms/ +``` + diff --git a/config/taldir-example.conf b/config/taldir-example.conf @@ -5,10 +5,11 @@ host = "https://taldir.gnunet.org" bind_to = "localhost:11000" salt = "ChangeMe" monthly_fee = KUDOS:1 -default_doc_filetype = text/markdown +default_doc_filetype = text/html default_doc_lang = en-US default_tos_path = terms/ default_pp_path = privacy/ +supported_doc_filetypes = text/html application/pdf application/epub application/xml text/plain challenge_bytes = 16 validation_initiation_max = 3 solution_attempt_max = 3 @@ -16,7 +17,7 @@ validation_timeframe = 10m solution_attempt_timeframe = 1h merchant_baseurl_private = http://merchant.taldir/instances/myInstance merchant_token = superSecretToken -validation_landing = testdata/templates/validation_landing.html +validation_landing = templates/validation_landing.html validation_expiration = 24h [taldir-email] diff --git a/pkg/rest/taldir.go b/pkg/rest/taldir.go @@ -639,7 +639,7 @@ func (t *Taldir) ClearDatabase() { } func (t *Taldir) termsResponse(w http.ResponseWriter, r *http.Request) { - fileType := t.Cfg.Section("taldir").Key("default_doc_filetype").MustString("text/markdown") + fileType := t.Cfg.Section("taldir").Key("default_doc_filetype").MustString("text/html") termsLocation := t.Cfg.Section("taldir").Key("default_tos_path").MustString("terms/") for _, typ := range r.Header["Accept"] { for _, a := range strings.Split(t.Cfg.Section("taldir").Key("supported_doc_filetypes").String(), " ") { @@ -654,8 +654,9 @@ func (t *Taldir) termsResponse(w http.ResponseWriter, r *http.Request) { for _, lang := range acceptLangs { extensions, _ := mime.ExtensionsByType(fileType) for _, ext := range extensions { - log.Printf("Trying %s\n", termsLocation + lang.String() + ext) - fileBytes, err := ioutil.ReadFile(termsLocation + lang.String() + ext) + docFile := fmt.Sprintf("%s/%s/0.%s", termsLocation, lang.String, ext) + log.Printf("Trying %s\n", docFile) + fileBytes, err := ioutil.ReadFile(docFile) if nil == err { w.Header().Set("Content-Type", fileType) w.Write(fileBytes) @@ -663,21 +664,23 @@ func (t *Taldir) termsResponse(w http.ResponseWriter, r *http.Request) { } } } - w.WriteHeader(404) + w.WriteHeader(http.StatusNotFound) return } // Default document in expected/default format - defaultLanguage := t.Cfg.Section("taldir").Key("default_doc_lang").MustString("en-US") + defaultLanguage := t.Cfg.Section("taldir").Key("default_doc_lang").MustString("en") extensions, _ := mime.ExtensionsByType(fileType) for _, ext := range extensions { - fileBytes, err := ioutil.ReadFile(termsLocation + defaultLanguage + ext) + docFile := fmt.Sprintf("%s/%s/0%s", termsLocation, defaultLanguage, ext) + log.Println("Trying " + docFile) + fileBytes, err := ioutil.ReadFile(docFile) if nil == err { w.Header().Set("Content-Type", fileType) w.Write(fileBytes) return } } - w.WriteHeader(404) + w.WriteHeader(http.StatusNotFound) } func (t *Taldir) privacyResponse(w http.ResponseWriter, r *http.Request) { @@ -696,8 +699,9 @@ func (t *Taldir) privacyResponse(w http.ResponseWriter, r *http.Request) { for _, lang := range acceptLangs { extensions, _ := mime.ExtensionsByType(fileType) for _, ext := range extensions { - log.Printf("Trying %s\n", termsLocation + lang.String() + ext) - fileBytes, err := ioutil.ReadFile(termsLocation + lang.String() + ext) + docFile := fmt.Sprintf("%s/%s/0.%s", termsLocation, lang.String, ext) + log.Printf("Trying %s\n", docFile) + fileBytes, err := ioutil.ReadFile(docFile) if nil == err { w.Header().Set("Content-Type", fileType) w.Write(fileBytes) @@ -705,21 +709,22 @@ func (t *Taldir) privacyResponse(w http.ResponseWriter, r *http.Request) { } } } - w.WriteHeader(404) + w.WriteHeader(http.StatusNotFound) return } // Default document in expected/default format - defaultLanguage := t.Cfg.Section("taldir").Key("default_doc_lang").MustString("en-US") + defaultLanguage := t.Cfg.Section("taldir").Key("default_doc_lang").MustString("en") extensions, _ := mime.ExtensionsByType(fileType) for _, ext := range extensions { - fileBytes, err := ioutil.ReadFile(termsLocation + defaultLanguage + ext) + docFile := fmt.Sprintf("%s/%s/0.%s", termsLocation, defaultLanguage, ext) + fileBytes, err := ioutil.ReadFile(docFile) if nil == err { w.Header().Set("Content-Type", fileType) w.Write(fileBytes) return } } - w.WriteHeader(404) + w.WriteHeader(http.StatusNotFound) } diff --git a/terms/de-DE.md b/terms/de-DE.md @@ -1 +0,0 @@ -# TOS