mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-09 10:28:21 +00:00
Fix MAX_GENERATED_CREDENTIALS_LENGTH for azure credentials
This commit is contained in:
+7
-2
@@ -37,15 +37,20 @@ export const azureClientSecretRotationFactory: TRotationFactory<
|
|||||||
await blockLocalAndPrivateIpAddresses(endpoint);
|
await blockLocalAndPrivateIpAddresses(endpoint);
|
||||||
|
|
||||||
const endDateTime = new Date();
|
const endDateTime = new Date();
|
||||||
console.log({ rotationInterval })
|
|
||||||
endDateTime.setDate(endDateTime.getDate() + rotationInterval);
|
endDateTime.setDate(endDateTime.getDate() + rotationInterval);
|
||||||
|
|
||||||
|
const now = new Date();
|
||||||
|
const formattedDate = `${String(now.getMonth() + 1).padStart(2, "0")}-${String(now.getDate()).padStart(
|
||||||
|
2,
|
||||||
|
"0"
|
||||||
|
)}-${now.getFullYear()}`;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const { data } = await request.post<AzureAddPasswordResponse>(
|
const { data } = await request.post<AzureAddPasswordResponse>(
|
||||||
endpoint,
|
endpoint,
|
||||||
{
|
{
|
||||||
passwordCredential: {
|
passwordCredential: {
|
||||||
displayName: "Infisical Auto-Rotated Secret",
|
displayName: `Infisical Rotated Secret (${formattedDate})`,
|
||||||
endDateTime: endDateTime.toISOString()
|
endDateTime: endDateTime.toISOString()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -815,6 +815,14 @@ export const secretRotationV2ServiceFactory = ({
|
|||||||
return expandSecretRotation(secretRotation, kmsService);
|
return expandSecretRotation(secretRotation, kmsService);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const getMaxGeneratedCredentialsLength = (rotationType: SecretRotation): number => {
|
||||||
|
if (rotationType === SecretRotation.AzureClientSecret) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return MAX_GENERATED_CREDENTIALS_LENGTH;
|
||||||
|
};
|
||||||
|
|
||||||
const rotateGeneratedCredentials = async (
|
const rotateGeneratedCredentials = async (
|
||||||
secretRotation: TSecretRotationV2Raw,
|
secretRotation: TSecretRotationV2Raw,
|
||||||
{
|
{
|
||||||
@@ -858,7 +866,7 @@ export const secretRotationV2ServiceFactory = ({
|
|||||||
kmsService
|
kmsService
|
||||||
});
|
});
|
||||||
|
|
||||||
const inactiveIndex = (activeIndex + 1) % MAX_GENERATED_CREDENTIALS_LENGTH;
|
const inactiveIndex = (activeIndex + 1) % getMaxGeneratedCredentialsLength(type as SecretRotation);
|
||||||
|
|
||||||
const inactiveCredentials = generatedCredentials[inactiveIndex];
|
const inactiveCredentials = generatedCredentials[inactiveIndex];
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user