From 15d37da667de5758001523ce972827791f4ddc5d Mon Sep 17 00:00:00 2001 From: timvisee Date: Mon, 12 Apr 2021 15:19:02 +0200 Subject: [PATCH] Remove obsolete anonymous limits Related to https://gitlab.com/timvisee/send/-/issues/3 --- app/user.js | 12 +++--------- server/clientConstants.js | 5 ----- server/config.js | 15 --------------- server/routes/params.js | 2 +- server/routes/ws.js | 12 +++--------- 5 files changed, 7 insertions(+), 39 deletions(-) diff --git a/app/user.js b/app/user.js index d1b28e3e..be3aef2a 100644 --- a/app/user.js +++ b/app/user.js @@ -81,21 +81,15 @@ export default class User { } get maxSize() { - return this.loggedIn - ? this.limits.MAX_FILE_SIZE - : this.limits.ANON.MAX_FILE_SIZE; + return this.limits.MAX_FILE_SIZE; } get maxExpireSeconds() { - return this.loggedIn - ? this.limits.MAX_EXPIRE_SECONDS - : this.limits.ANON.MAX_EXPIRE_SECONDS; + return this.limits.MAX_EXPIRE_SECONDS; } get maxDownloads() { - return this.loggedIn - ? this.limits.MAX_DOWNLOADS - : this.limits.ANON.MAX_DOWNLOADS; + return this.limits.MAX_DOWNLOADS; } async metricId() { diff --git a/server/clientConstants.js b/server/clientConstants.js index 0ac85d86..74bf48a5 100644 --- a/server/clientConstants.js +++ b/server/clientConstants.js @@ -2,11 +2,6 @@ const config = require('./config'); module.exports = { LIMITS: { - ANON: { - MAX_FILE_SIZE: config.anon_max_file_size, - MAX_DOWNLOADS: config.anon_max_downloads, - MAX_EXPIRE_SECONDS: config.anon_max_expire_seconds - }, MAX_FILE_SIZE: config.max_file_size, MAX_DOWNLOADS: config.max_downloads, MAX_EXPIRE_SECONDS: config.max_expire_seconds, diff --git a/server/config.js b/server/config.js index 2c799673..e6113e48 100644 --- a/server/config.js +++ b/server/config.js @@ -39,11 +39,6 @@ const conf = convict({ default: 86400 * 7, env: 'MAX_EXPIRE_SECONDS' }, - anon_max_expire_seconds: { - format: Number, - default: 86400, - env: 'ANON_MAX_EXPIRE_SECONDS' - }, download_counts: { format: Array, default: [1, 2, 3, 4, 5, 20, 50, 100], @@ -54,11 +49,6 @@ const conf = convict({ default: 100, env: 'MAX_DOWNLOADS' }, - anon_max_downloads: { - format: Number, - default: 5, - env: 'ANON_MAX_DOWNLOADS' - }, max_files_per_archive: { format: Number, default: 64, @@ -120,11 +110,6 @@ const conf = convict({ default: 1024 * 1024 * 1024 * 2.5, env: 'MAX_FILE_SIZE' }, - anon_max_file_size: { - format: Number, - default: 1024 * 1024 * 1024, - env: 'ANON_MAX_FILE_SIZE' - }, l10n_dev: { format: Boolean, default: false, diff --git a/server/routes/params.js b/server/routes/params.js index 08e22f25..bc04eb35 100644 --- a/server/routes/params.js +++ b/server/routes/params.js @@ -2,7 +2,7 @@ const config = require('../config'); const storage = require('../storage'); module.exports = function(req, res) { - const max = req.user ? config.max_downloads : config.anon_max_downloads; + const max = config.max_downloads; const dlimit = req.body.dlimit; if (!dlimit || dlimit > max) { return res.sendStatus(400); diff --git a/server/routes/ws.js b/server/routes/ws.js index 7e89a180..b378f383 100644 --- a/server/routes/ws.js +++ b/server/routes/ws.js @@ -30,15 +30,9 @@ module.exports = function(ws, req) { const metadata = fileInfo.fileMetadata; const auth = fileInfo.authorization; const user = await fxa.verify(fileInfo.bearer); - const maxFileSize = user - ? config.max_file_size - : config.anon_max_file_size; - const maxExpireSeconds = user - ? config.max_expire_seconds - : config.anon_max_expire_seconds; - const maxDownloads = user - ? config.max_downloads - : config.anon_max_downloads; + const maxFileSize = config.max_file_size; + const maxExpireSeconds = config.max_expire_seconds; + const maxDownloads = config.max_downloads; if (config.fxa_required && !user) { ws.send(