Disable Access Key option.

This commit is contained in:
ZizzyDizzyMC 2021-02-22 13:32:38 -05:00
parent 797a61cf5c
commit cd79f0db40
4 changed files with 9 additions and 1 deletions

View File

@ -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()

View File

@ -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 == "" {

View File

@ -34,6 +34,7 @@
</select>
</label>
</div>
{% if disable_access_key != true %}
<div id="access_key">
<span class="hint--top hint--bounce"
data-hint="Require password to access (this does not encrypt the file but only limits access)">
@ -44,6 +45,7 @@
<input id="access_key_input" name="access_key" type="text" placeholder="Access password" />
</span>
</div>
{% endif %}
</div>
<div class="clear"></div>
</form>

View File

@ -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