load max file size and file lifetime from a separate insecure config

This commit is contained in:
Peter Cai 2020-02-19 20:32:57 +08:00
parent 2eb9ce10fc
commit 13bc689305
No known key found for this signature in database
GPG Key ID: 71F5FB4E4F3FD54F
4 changed files with 20 additions and 4 deletions

3
.gitignore vendored
View File

@ -9,4 +9,5 @@ worker/
node_modules/ node_modules/
.cargo-ok .cargo-ok
wrangler.toml wrangler.toml
config.json config.json
config.insecure.json

View File

@ -0,0 +1,5 @@
{
"comments": "This file contains configuration that will be load into the browser frontend. See src/util.coffee for details.",
"max_upload_size": 10485760,
"file_lifetime": "7 days"
}

View File

@ -1,7 +1,16 @@
import configInsec from "../config.insecure.json"
import { detect as detectBrowser } from 'detect-browser' import { detect as detectBrowser } from 'detect-browser'
# The following two items are read from `config.insecure.json`
# These configuration will be load into the frontend, so make sure
# no sensitive information is leaked through the json
# Maximum upload size (in bytes) # Maximum upload size (in bytes)
MAX_UPLOAD_SIZE = 10 * 1024 * 1024 # 10 MB MAX_UPLOAD_SIZE = configInsec.max_upload_size
# File lifetime (deleted after X days)
# This is only intended for human, any auto-deletion
# should be configured in your S3 bucket
FILE_LIFETIME = configInsec.file_lifetime
# Maximum file name length # Maximum file name length
MAX_FILENAME_LENGTH = 255 # bytes MAX_FILENAME_LENGTH = 255 # bytes
@ -91,5 +100,6 @@ export {
isText, isText,
progressText, progressText,
humanFileSize, humanFileSize,
MAX_FILENAME_LENGTH MAX_FILENAME_LENGTH,
FILE_LIFETIME
} }

View File

@ -19,7 +19,7 @@ class HelpButton extends React.Component
There is <strong>absolutely no guarantee</strong> on its functionality, security and reliability. There is <strong>absolutely no guarantee</strong> on its functionality, security and reliability.
</p> </p>
<p> <p>
<strong>Maximum file size: {util.humanFileSize util.MAX_UPLOAD_SIZE}</strong>, all uploads are kept for <strong>7 days</strong> only. <strong>Maximum file size: {util.humanFileSize util.MAX_UPLOAD_SIZE}</strong>, all uploads are kept for <strong>{util.FILE_LIFETIME}</strong> only.
</p> </p>
<p> <p>
File uploads with <strong>"Encryption: ON"</strong> are encrypted with <i>AES-128-GCM</i> before uploading to server. File uploads with <strong>"Encryption: ON"</strong> are encrypted with <i>AES-128-GCM</i> before uploading to server.