From ecf613e0e0f7e52a2824b5a5e23803baec3bfef4 Mon Sep 17 00:00:00 2001 From: Maarten Date: Wed, 9 Sep 2020 00:40:02 +0200 Subject: [PATCH] [FIX] Create Custom OAuth services from environment variables (#17377) --- app/lib/server/startup/oAuthServicesUpdate.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/lib/server/startup/oAuthServicesUpdate.js b/app/lib/server/startup/oAuthServicesUpdate.js index c022f6098335..d27af42e40f0 100644 --- a/app/lib/server/startup/oAuthServicesUpdate.js +++ b/app/lib/server/startup/oAuthServicesUpdate.js @@ -132,3 +132,15 @@ settings.get(/^Accounts_OAuth_Custom-[a-z0-9_]+/, function(key, value) { return OAuthServicesRemove(key);// eslint-disable-line new-cap } }); + +function customOAuthServicesInit() { + // Add settings for custom OAuth providers to the settings so they get + // automatically added when they are defined in ENV variables + Object.keys(process.env).forEach((key) => { + if (/Accounts_OAuth_Custom-[a-zA-Z0-9_-]+$/.test(key)) { + settings.add(key, process.env[key]); + } + }); +} + +customOAuthServicesInit();