Merge pull request #2923 from Infisical/akhilmhdh-patch-azure

fix: resolved azure app config api not pulling all keys
This commit is contained in:
Sheen
2024-12-30 23:19:54 +08:00
committed by GitHub
@@ -305,10 +305,16 @@ const syncSecretsAzureAppConfig = async ({
value: string; value: string;
} }
const getCompleteAzureAppConfigValues = async (url: string) => { if (!integration.app || !integration.app.endsWith(".azconfig.io"))
throw new BadRequestError({
message: "Invalid Azure App Configuration URL provided."
});
const getCompleteAzureAppConfigValues = async (baseURL: string, url: string) => {
let result: AzureAppConfigKeyValue[] = []; let result: AzureAppConfigKeyValue[] = [];
while (url) { while (url) {
const res = await request.get(url, { const res = await request.get(url, {
baseURL,
headers: { headers: {
Authorization: `Bearer ${accessToken}` Authorization: `Bearer ${accessToken}`
}, },
@@ -319,7 +325,7 @@ const syncSecretsAzureAppConfig = async ({
}); });
result = result.concat(res.data.items); result = result.concat(res.data.items);
url = res.data.nextLink; url = res.data?.["@nextLink"];
} }
return result; return result;
@@ -327,11 +333,13 @@ const syncSecretsAzureAppConfig = async ({
const metadata = IntegrationMetadataSchema.parse(integration.metadata); const metadata = IntegrationMetadataSchema.parse(integration.metadata);
const azureAppConfigValuesUrl = `${integration.app}/kv?api-version=2023-11-01&key=${metadata.secretPrefix}*${ const azureAppConfigValuesUrl = `/kv?api-version=2023-11-01&key=${metadata.secretPrefix}*${
metadata.azureLabel ? `&label=${metadata.azureLabel}` : "&label=%00" metadata.azureLabel ? `&label=${metadata.azureLabel}` : "&label=%00"
}`; }`;
const azureAppConfigSecrets = (await getCompleteAzureAppConfigValues(azureAppConfigValuesUrl)).reduce( const azureAppConfigSecrets = (
await getCompleteAzureAppConfigValues(integration.app, azureAppConfigValuesUrl)
).reduce(
(accum, entry) => { (accum, entry) => {
accum[entry.key] = entry.value; accum[entry.key] = entry.value;