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 {