From fdae9251b51129f41a316ff786cf5fa66bdcc99d Mon Sep 17 00:00:00 2001 From: Lorenzo Mangani Date: Wed, 12 Apr 2023 23:35:39 +0200 Subject: [PATCH] Update quackpipe.go --- quackpipe.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/quackpipe.go b/quackpipe.go index 18f0a62..99fd09d 100644 --- a/quackpipe.go +++ b/quackpipe.go @@ -1,6 +1,7 @@ package main import ( + "crypto/sha256" "bufio" "database/sql" _ "embed" @@ -326,6 +327,14 @@ func main() { if r.URL.Query().Get("default_params") != "" { default_params = r.URL.Query().Get("default_params") } + // auth to hash based temp file storage + username, password, ok := r.BasicAuth() + if ok && len(password) > 0 { + hash := sha256.Sum256([]byte(username + password)) + hashdb, _ := fmt.Printf("/tmp/%x.db", hash) + repath := regexp.MustCompile(`(.*?)\?`) + default_params = repath.ReplaceAllString(default_params, repath+"?") + } // extract FORMAT from query and override the current `default_format` cleanquery, format := extractAndRemoveFormat(query) if len(format) > 0 {