mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-08 20:28:16 +00:00
Fix bug on azure revokeCredentials and limit expiration to 5 years
This commit is contained in:
+14
-2
@@ -1,3 +1,4 @@
|
|||||||
|
/* eslint-disable no-await-in-loop */
|
||||||
import { AxiosError } from "axios";
|
import { AxiosError } from "axios";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@@ -18,6 +19,11 @@ import { getAzureConnectionAccessToken } from "@app/services/app-connection/azur
|
|||||||
|
|
||||||
const GRAPH_API_BASE = "https://graph.microsoft.com/v1.0";
|
const GRAPH_API_BASE = "https://graph.microsoft.com/v1.0";
|
||||||
|
|
||||||
|
const sleep = async () =>
|
||||||
|
new Promise((resolve) => {
|
||||||
|
setTimeout(resolve, 1000);
|
||||||
|
});
|
||||||
|
|
||||||
export const azureClientSecretRotationFactory: TRotationFactory<
|
export const azureClientSecretRotationFactory: TRotationFactory<
|
||||||
TAzureClientSecretRotationWithConnection,
|
TAzureClientSecretRotationWithConnection,
|
||||||
TAzureClientSecretRotationGeneratedCredentials
|
TAzureClientSecretRotationGeneratedCredentials
|
||||||
@@ -41,13 +47,16 @@ export const azureClientSecretRotationFactory: TRotationFactory<
|
|||||||
"0"
|
"0"
|
||||||
)}-${now.getFullYear()}`;
|
)}-${now.getFullYear()}`;
|
||||||
|
|
||||||
|
const endDateTime = new Date();
|
||||||
|
endDateTime.setFullYear(now.getFullYear() + 5);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const { data } = await request.post<AzureAddPasswordResponse>(
|
const { data } = await request.post<AzureAddPasswordResponse>(
|
||||||
endpoint,
|
endpoint,
|
||||||
{
|
{
|
||||||
passwordCredential: {
|
passwordCredential: {
|
||||||
displayName: `Infisical Rotated Secret (${formattedDate})`,
|
displayName: `Infisical Rotated Secret (${formattedDate})`,
|
||||||
endDateTime: "2299-12-31T23:59:59Z" // effectively no expiration
|
endDateTime: endDateTime.toISOString()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -130,7 +139,10 @@ export const azureClientSecretRotationFactory: TRotationFactory<
|
|||||||
) => {
|
) => {
|
||||||
if (!credentials?.length) return callback();
|
if (!credentials?.length) return callback();
|
||||||
|
|
||||||
await Promise.all(credentials.map(({ keyId }) => revokeCredential(keyId)));
|
for (const { keyId } of credentials) {
|
||||||
|
await revokeCredential(keyId);
|
||||||
|
await sleep();
|
||||||
|
}
|
||||||
return callback();
|
return callback();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user