Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions examples/console-app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

145 changes: 105 additions & 40 deletions examples/web-app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/web-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"@azure/app-configuration-provider": "latest",
"@azure/identity": "^4.1.0",
"dotenv": "^16.3.1",
"express": "^4.21.2"
"express": "^4.22.1"
}
}
9 changes: 7 additions & 2 deletions src/keyvault/keyVaultSecretProvider.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

import { KeyVaultOptions } from "./keyVaultOptions.js";
import { KeyVaultOptions, MIN_SECRET_REFRESH_INTERVAL_IN_MS } from "./keyVaultOptions.js";
import { RefreshTimer } from "../refresh/refreshTimer.js";
import { ArgumentError } from "../common/errors.js";
import { SecretClient, KeyVaultSecretIdentifier } from "@azure/keyvault-secrets";
Expand All @@ -10,6 +10,7 @@ import { KeyVaultReferenceErrorMessages } from "../common/errorMessages.js";
export class AzureKeyVaultSecretProvider {
#keyVaultOptions: KeyVaultOptions | undefined;
#secretRefreshTimer: RefreshTimer | undefined;
#minSecretRefreshTimer: RefreshTimer;
#secretClients: Map<string, SecretClient>; // map key vault hostname to corresponding secret client
#cachedSecretValues: Map<string, any> = new Map<string, any>(); // map secret identifier to secret value

Expand All @@ -24,6 +25,7 @@ export class AzureKeyVaultSecretProvider {
}
this.#keyVaultOptions = keyVaultOptions;
this.#secretRefreshTimer = refreshTimer;
this.#minSecretRefreshTimer = new RefreshTimer(MIN_SECRET_REFRESH_INTERVAL_IN_MS);
this.#secretClients = new Map();
for (const client of this.#keyVaultOptions?.secretClients ?? []) {
const clientUrl = new URL(client.vaultUrl);
Expand All @@ -47,7 +49,10 @@ export class AzureKeyVaultSecretProvider {
}

clearCache(): void {
this.#cachedSecretValues.clear();
if (this.#minSecretRefreshTimer.canRefresh()) {
this.#cachedSecretValues.clear();
this.#minSecretRefreshTimer.reset();
}
}

async #getSecretValueFromKeyVault(secretIdentifier: KeyVaultSecretIdentifier): Promise<unknown> {
Expand Down
5 changes: 1 addition & 4 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ export type SettingSelector = {
* @remarks
* An asterisk `*` can be added to the end to return all key-values whose key begins with the key filter.
* e.g. key filter `abc*` returns all key-values whose key starts with `abc`.
* A comma `,` can be used to select multiple key-values. Comma separated filters must exactly match a key to select it.
* Using asterisk to select key-values that begin with a key filter while simultaneously using comma separated key filters is not supported.
* E.g. the key filter `abc*,def` is not supported. The key filters `abc*` and `abc,def` are supported.
* For all other cases the characters: asterisk `*`, comma `,`, and backslash `\` are reserved. Reserved characters must be escaped using a backslash (\).
* Characters: asterisk `*`, comma `,`, and backslash `\` are reserved. Reserved characters must be escaped using a backslash (\).
* e.g. the key filter `a\\b\,\*c*` returns all key-values whose key starts with `a\b,*c`.
*/
keyFilter?: string,
Expand Down
Loading