Skip to content

Commit 2095fc1

Browse files
committed
Add support for config_provider_time_to_live parameter in configuration provider plugin
1 parent bdb4f85 commit 2095fc1

File tree

3 files changed

+25
-13
lines changed

3 files changed

+25
-13
lines changed

doc/src/release_notes.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ Common Changes
4646
Thin Mode Changes
4747
+++++++++++++++++
4848

49+
#) Added support for the config_time_to_live parameter for configurations
50+
retrieved from centralized configuration providers.
51+
4952
#) Fixed bug validating the database host during connection.
5053

5154
#) Enabled proxy user to be passed with :ref:`external authentication <extauth>`

lib/oracledb.js

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -917,6 +917,7 @@ async function _setConfigParameters(obj, credential, configProvider) {
917917
configObject[key] = val;
918918
}
919919
configObject.connectString = obj.connect_descriptor;
920+
configObject.configTTL = obj.config_time_to_live;
920921
if (!configObject.connectString)
921922
errors.throwErr(errors.ERR_CONFIG_PROVIDER_FAILED_TO_RETRIEVE_CONFIG, 'connect_descriptor must be set');
922923

@@ -989,32 +990,37 @@ async function _retrieveParamValueFromVault(paramObj, credential, configProvider
989990
//-----------------------------------------------------------------------------
990991
// _checkConfigProvider()
991992
//
992-
// Look for the config provider in the connection string and retreives
993+
// Look for the config provider in the connection string and retrieves
993994
// object stored in the config Provider.
994995
// Returns object based on precedence between input object and the one retrieved
995996
// from Config Provider.
996997
//-----------------------------------------------------------------------------
997998
async function _checkConfigProvider(options) {
998999
// Time for Cache entries to be deleted in milliseconds
999-
const cacheEntriesDuration = settings.configProviderCacheTimeout * 1000;
1000-
let secondOpts;
1000+
let cacheEntriesDuration = settings.configProviderCacheTimeout * 1000;
1001+
let secondOpts, cachedConfigEntry;
10011002
const url = options.connectString || options.connectionString;
10021003
if (!url)
10031004
return options;
10041005

1005-
if (configProviderCache && configProviderCache.has(url) && ((Date.now() - configProviderCache.get(url).timeAdded) < cacheEntriesDuration)) {
1006-
const cacheOpts1 = configProviderCache.get(url).cacheOpts;
1007-
secondOpts = { ...cacheOpts1};
1006+
if (configProviderCache && (cachedConfigEntry = configProviderCache.get(url))) {
1007+
const config = cachedConfigEntry.cacheOpts;
1008+
if (config.configTTL)
1009+
cacheEntriesDuration = config.configTTL * 1000;
10081010

1009-
//deobfuscate password
1010-
if (secondOpts.password)
1011-
secondOpts.password = protocolUtil.getDeobfuscatedValue(secondOpts.password.value, secondOpts.password.obfuscatedValue);
1011+
if ((Date.now() - cachedConfigEntry.timeAdded) < cacheEntriesDuration) {
1012+
secondOpts = { ...config};
10121013

1013-
//deobfuscate walletContent
1014-
if (secondOpts.walletContent)
1015-
secondOpts.walletContent = protocolUtil.getDeobfuscatedValue(secondOpts.walletContent.value, secondOpts.walletContent.obfuscatedValue);
1014+
//deobfuscate password
1015+
if (secondOpts.password)
1016+
secondOpts.password = protocolUtil.getDeobfuscatedValue(secondOpts.password.value, secondOpts.password.obfuscatedValue);
10161017

1017-
} else {
1018+
//deobfuscate walletContent
1019+
if (secondOpts.walletContent)
1020+
secondOpts.walletContent = protocolUtil.getDeobfuscatedValue(secondOpts.walletContent.value, secondOpts.walletContent.obfuscatedValue);
1021+
}
1022+
}
1023+
if (!secondOpts) {
10181024
let parsedUrl = url;
10191025
let urlExtendedPart;
10201026
const baseRegex = new RegExp("^config-(?<provider>[A-Za-z0-9]+)(://)(?<provider_arg>[^?]+)");

plugins/configProviders/azure/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,9 @@ class AzureProvider extends base {
128128
//retrieve password
129129
configObject.password = await this.retrieveParamValueFromAzureConfigurationProvider(client, label, 'password');
130130

131+
// retrieve config_time_to_live
132+
configObject.configTTL = await this.retrieveParamValueFromAzureConfigurationProvider(client, label, 'config_time_to_live');
133+
131134
// retrieve wallet_location
132135
configObject.walletContent = await this.retrieveParamValueFromAzureConfigurationProvider(client, label, 'wallet_location');
133136

0 commit comments

Comments
 (0)