diff --git a/server.go b/server.go index 08f3b7b..6b106bb 100644 --- a/server.go +++ b/server.go @@ -313,7 +313,7 @@ func main() { "Extra text above the footer for notices.") flag.Uint64Var(&Config.maxDurationTime, "max-duration-time", 0, "Time till expiry for files over max-duration-size") flag.Int64Var(&Config.maxDurationSize, "max-duration-size", 4*1024*1024*1024, "Size of file before max-duration-time is used to determine expiry max time.") - + flag.BoolVar(&Config.disableAccessKey, "disable-access-key", false, "Disables access key usage") iniflags.Parse() mux := setup() diff --git a/templates.go b/templates.go index 6dcf852..51e9433 100644 --- a/templates.go +++ b/templates.go @@ -87,7 +87,10 @@ func renderTemplate(tpl *pongo2.Template, context pongo2.Context, r *http.Reques context["sitepath"] = Config.sitePath context["selifpath"] = Config.selifPath context["custom_pages_names"] = customPagesNames + // Add the context for Config.extraFooterText context["extra_footer_text"] = Config.extraFooterText + // Add the context for Config.disableAccessKey + context["disable_access_key"] = Config.disableAccessKey var a string if Config.authFile == "" { diff --git a/templates/index.html b/templates/index.html index 34e5d86..294ec40 100644 --- a/templates/index.html +++ b/templates/index.html @@ -34,6 +34,7 @@ + {% if disable_access_key != true %}
@@ -44,6 +45,7 @@
+ {% endif %}
diff --git a/upload.go b/upload.go index 7676274..bd2b948 100644 --- a/upload.go +++ b/upload.go @@ -338,6 +338,9 @@ func processUpload(upReq UploadRequest) (upload Upload, err error) { if upReq.deleteKey == "" { upReq.deleteKey = uniuri.NewLen(30) } + if Config.disableAccessKey == true { + upReq.accessKey = "" + } upload.Metadata, err = storageBackend.Put(upload.Filename, io.MultiReader(bytes.NewReader(header), upReq.src), fileExpiry, upReq.deleteKey, upReq.accessKey, upReq.srcIp) if err != nil { return upload, err