Add REDIS_USER and REDIS_DB configuration variables

See https://github.com/timvisee/send/issues/23#issuecomment-843925819
This commit is contained in:
timvisee 2021-05-19 11:59:35 +02:00
parent e5d7378fd9
commit 175712cfbd
No known key found for this signature in database
GPG Key ID: B8DB720BC383E172
3 changed files with 16 additions and 2 deletions

View File

@ -58,13 +58,13 @@ Pick how you want to store uploaded files and set these config options according
- Local filesystem (the default): set `FILE_DIR` to the local path used inside the container for storage (or leave the default) - Local filesystem (the default): set `FILE_DIR` to the local path used inside the container for storage (or leave the default)
- S3-compatible object store: set `S3_BUCKET`, `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY` (and `S3_ENDPOINT` if using something other than AWS) - S3-compatible object store: set `S3_BUCKET`, `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY` (and `S3_ENDPOINT` if using something other than AWS)
- Google Cloud Storage: set `GCS_BUCKET` to the name of a GCS bucket (auth should be set up using [Application Default Credentials](https://cloud.google.com/docs/authentication/production#auth-cloud-implicit-nodejs)) - Google Cloud Storage: set `GCS_BUCKET` to the name of a GCS bucket (auth should be set up using [Application Default Credentials](https://cloud.google.com/docs/authentication/production#auth-cloud-implicit-nodejs))
Redis is used as the metadata database for the backend and is required no matter which storage method you use. Redis is used as the metadata database for the backend and is required no matter which storage method you use.
| Name | Description | | Name | Description |
|------------------|-------------| |------------------|-------------|
| `REDIS_HOST`, `REDIS_PORT`, `REDIS_PASSWORD` | Host name, port, and pass of the Redis server (defaults to `localhost`, `6379`, and no password) | `REDIS_HOST`, `REDIS_PORT`, `REDIS_USER`, `REDIS_PASSWORD`, `REDIS_DB` | Host name, port, and pass of the Redis server (defaults to `localhost`, `6379`, and no password)
| `FILE_DIR` | Directory for storage inside the Docker container (defaults to `/uploads`) | `FILE_DIR` | Directory for storage inside the Docker container (defaults to `/uploads`)
| `S3_BUCKET` | The S3 bucket name to use (only set if using S3 for storage) | `S3_BUCKET` | The S3 bucket name to use (only set if using S3 for storage)
| `S3_ENDPOINT` | An optional custom endpoint to use for S3 (defaults to AWS) | `S3_ENDPOINT` | An optional custom endpoint to use for S3 (defaults to AWS)

View File

@ -89,11 +89,21 @@ const conf = convict({
default: 6379, default: 6379,
env: 'REDIS_PORT' env: 'REDIS_PORT'
}, },
redis_user: {
format: String,
default: '',
env: 'REDIS_USER'
},
redis_password: { redis_password: {
format: String, format: String,
default: '', default: '',
env: 'REDIS_PASSWORD' env: 'REDIS_PASSWORD'
}, },
redis_db: {
format: String,
default: '',
env: 'REDIS_DB'
},
redis_event_expire: { redis_event_expire: {
format: Boolean, format: Boolean,
default: false, default: false,

View File

@ -21,8 +21,12 @@ module.exports = function(config) {
return config.redis_retry_delay; return config.redis_retry_delay;
} }
}; };
if (config.redis_user != null && config.redis_user.length > 0)
client_config.user = config.redis_user;
if (config.redis_password != null && config.redis_password.length > 0) if (config.redis_password != null && config.redis_password.length > 0)
client_config.password = config.redis_password; client_config.password = config.redis_password;
if (config.redis_db != null && config.redis_db.length > 0)
client_config.db = config.redis_db;
const client = redis.createClient(client_config); const client = redis.createClient(client_config);
client.ttlAsync = promisify(client.ttl); client.ttlAsync = promisify(client.ttl);