summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnderson Entwistle <46688047+aentwist@users.noreply.github.com>2023-03-28 09:50:55 -0400
committerGitHub <noreply@github.com>2023-03-28 13:50:55 +0000
commite1b19238615970db8d0e8bf3d15601613da28adc (patch)
treed5fa41750b1054ef9294d1e7b34522f7e52f9ba1
parent1ca0f40af4fee78051c3870f41e169c9da1bdcba (diff)
feat: support object store credentials from file (#1946)
Signed-off-by: Anderson Entwistle <46688047+aentwist@users.noreply.github.com>
-rw-r--r--.config/s3.config.php18
-rw-r--r--README.md2
2 files changed, 17 insertions, 3 deletions
diff --git a/.config/s3.config.php b/.config/s3.config.php
index aa3f4f59..6d0ede91 100644
--- a/.config/s3.config.php
+++ b/.config/s3.config.php
@@ -9,8 +9,6 @@ if (getenv('OBJECTSTORE_S3_BUCKET')) {
'class' => '\OC\Files\ObjectStore\S3',
'arguments' => array(
'bucket' => getenv('OBJECTSTORE_S3_BUCKET'),
- 'key' => getenv('OBJECTSTORE_S3_KEY') ?: '',
- 'secret' => getenv('OBJECTSTORE_S3_SECRET') ?: '',
'region' => getenv('OBJECTSTORE_S3_REGION') ?: '',
'hostname' => getenv('OBJECTSTORE_S3_HOST') ?: '',
'port' => getenv('OBJECTSTORE_S3_PORT') ?: '',
@@ -24,4 +22,20 @@ if (getenv('OBJECTSTORE_S3_BUCKET')) {
)
)
);
+
+ if (getenv('OBJECTSTORE_S3_KEY_FILE') && file_exists(getenv('OBJECTSTORE_S3_KEY_FILE'))) {
+ $CONFIG['objectstore']['arguments']['key'] = trim(file_get_contents(getenv('OBJECTSTORE_S3_KEY_FILE')));
+ } elseif (getenv('OBJECTSTORE_S3_KEY')) {
+ $CONFIG['objectstore']['arguments']['key'] = getenv('OBJECTSTORE_S3_KEY');
+ } else {
+ $CONFIG['objectstore']['arguments']['key'] = '';
+ }
+
+ if (getenv('OBJECTSTORE_S3_SECRET_FILE') && file_exists(getenv('OBJECTSTORE_S3_SECRET_FILE'))) {
+ $CONFIG['objectstore']['arguments']['secret'] = trim(file_get_contents(getenv('OBJECTSTORE_S3_SECRET_FILE')));
+ } elseif (getenv('OBJECTSTORE_S3_SECRET')) {
+ $CONFIG['objectstore']['arguments']['secret'] = getenv('OBJECTSTORE_S3_SECRET');
+ } else {
+ $CONFIG['objectstore']['arguments']['secret'] = '';
+ }
}
diff --git a/README.md b/README.md
index 267df3b8..76e7ef4e 100644
--- a/README.md
+++ b/README.md
@@ -386,7 +386,7 @@ secrets:
file: ./postgres_user.txt # put postgresql username in this file
```
-Currently, this is only supported for `NEXTCLOUD_ADMIN_PASSWORD`, `NEXTCLOUD_ADMIN_USER`, `MYSQL_DATABASE`, `MYSQL_PASSWORD`, `MYSQL_USER`, `POSTGRES_DB`, `POSTGRES_PASSWORD`, `POSTGRES_USER`, `REDIS_HOST_PASSWORD` and `SMTP_PASSWORD`.
+Currently, this is only supported for `NEXTCLOUD_ADMIN_PASSWORD`, `NEXTCLOUD_ADMIN_USER`, `MYSQL_DATABASE`, `MYSQL_PASSWORD`, `MYSQL_USER`, `POSTGRES_DB`, `POSTGRES_PASSWORD`, `POSTGRES_USER`, `REDIS_HOST_PASSWORD`, `SMTP_PASSWORD`, `OBJECTSTORE_S3_KEY`, and `OBJECTSTORE_S3_SECRET`.
If you set any group of values (i.e. all of `MYSQL_DATABASE_FILE`, `MYSQL_USER_FILE`, `MYSQL_PASSWORD_FILE`, `MYSQL_HOST`), the script will not use the corresponding group of environment variables (`MYSQL_DATABASE`, `MYSQL_USER`, `MYSQL_PASSWORD`, `MYSQL_HOST`).