mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 00:27:30 +00:00
Rename azure flag to enableVersions
This commit is contained in:
+4
-4
@@ -3,6 +3,7 @@ import * as AWS from "aws-sdk";
|
|||||||
import RE2 from "re2";
|
import RE2 from "re2";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
|
||||||
|
import { TCertificateSyncs } from "@app/db/schemas";
|
||||||
import { BadRequestError, NotFoundError } from "@app/lib/errors";
|
import { BadRequestError, NotFoundError } from "@app/lib/errors";
|
||||||
import { logger } from "@app/lib/logger";
|
import { logger } from "@app/lib/logger";
|
||||||
import { TAppConnectionDALFactory } from "@app/services/app-connection/app-connection-dal";
|
import { TAppConnectionDALFactory } from "@app/services/app-connection/app-connection-dal";
|
||||||
@@ -397,11 +398,10 @@ export const awsCertificateManagerPkiSyncFactory = ({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const existingSyncRecords = await certificateSyncDAL.findByPkiSyncId(pkiSync.id);
|
const existingSyncRecords = await certificateSyncDAL.findByPkiSyncId(pkiSync.id);
|
||||||
type SyncRecord = (typeof existingSyncRecords)[0];
|
const syncRecordsByCertId = new Map<string, TCertificateSyncs>();
|
||||||
const syncRecordsByCertId = new Map<string, SyncRecord>();
|
const syncRecordsByExternalId = new Map<string, TCertificateSyncs>();
|
||||||
const syncRecordsByExternalId = new Map<string, SyncRecord>();
|
|
||||||
|
|
||||||
existingSyncRecords.forEach((record: SyncRecord) => {
|
existingSyncRecords.forEach((record: TCertificateSyncs) => {
|
||||||
if (record.certificateId) {
|
if (record.certificateId) {
|
||||||
syncRecordsByCertId.set(record.certificateId, record);
|
syncRecordsByCertId.set(record.certificateId, record);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
import { AxiosError } from "axios";
|
import { AxiosError } from "axios";
|
||||||
import * as crypto from "crypto";
|
import * as crypto from "crypto";
|
||||||
|
|
||||||
|
import { TCertificateSyncs } from "@app/db/schemas";
|
||||||
import { request } from "@app/lib/config/request";
|
import { request } from "@app/lib/config/request";
|
||||||
import { logger } from "@app/lib/logger";
|
import { logger } from "@app/lib/logger";
|
||||||
import { TAppConnectionDALFactory } from "@app/services/app-connection/app-connection-dal";
|
import { TAppConnectionDALFactory } from "@app/services/app-connection/app-connection-dal";
|
||||||
@@ -346,11 +347,10 @@ export const azureKeyVaultPkiSyncFactory = ({
|
|||||||
);
|
);
|
||||||
|
|
||||||
const existingSyncRecords = await certificateSyncDAL.findByPkiSyncId(pkiSync.id);
|
const existingSyncRecords = await certificateSyncDAL.findByPkiSyncId(pkiSync.id);
|
||||||
type SyncRecord = (typeof existingSyncRecords)[0];
|
const syncRecordsByCertId = new Map<string, TCertificateSyncs>();
|
||||||
const syncRecordsByCertId = new Map<string, SyncRecord>();
|
const syncRecordsByExternalId = new Map<string, TCertificateSyncs>();
|
||||||
const syncRecordsByExternalId = new Map<string, SyncRecord>();
|
|
||||||
|
|
||||||
existingSyncRecords.forEach((record: SyncRecord) => {
|
existingSyncRecords.forEach((record: TCertificateSyncs) => {
|
||||||
if (record.certificateId) {
|
if (record.certificateId) {
|
||||||
syncRecordsByCertId.set(record.certificateId, record);
|
syncRecordsByCertId.set(record.certificateId, record);
|
||||||
}
|
}
|
||||||
@@ -368,10 +368,10 @@ export const azureKeyVaultPkiSyncFactory = ({
|
|||||||
}[] = [];
|
}[] = [];
|
||||||
|
|
||||||
const syncOptions = pkiSync.syncOptions as
|
const syncOptions = pkiSync.syncOptions as
|
||||||
| { certificateNameSchema?: string; canRemoveCertificates?: boolean; preserveVersion?: boolean }
|
| { certificateNameSchema?: string; canRemoveCertificates?: boolean; enableVersioning?: boolean }
|
||||||
| undefined;
|
| undefined;
|
||||||
const canRemoveCertificates = syncOptions?.canRemoveCertificates ?? true;
|
const canRemoveCertificates = syncOptions?.canRemoveCertificates ?? true;
|
||||||
const preserveVersion = syncOptions?.preserveVersion ?? true;
|
const enableVersioning = syncOptions?.enableVersioning ?? true;
|
||||||
|
|
||||||
const activeExternalIdentifiers = new Set<string>();
|
const activeExternalIdentifiers = new Set<string>();
|
||||||
|
|
||||||
@@ -382,7 +382,7 @@ export const azureKeyVaultPkiSyncFactory = ({
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (preserveVersion && typeof certificateId === "string") {
|
if (enableVersioning && typeof certificateId === "string") {
|
||||||
const certificate = await certificateDAL.findById(certificateId);
|
const certificate = await certificateDAL.findById(certificateId);
|
||||||
if (certificate?.renewedByCertificateId) {
|
if (certificate?.renewedByCertificateId) {
|
||||||
// eslint-disable-next-line no-continue
|
// eslint-disable-next-line no-continue
|
||||||
@@ -399,7 +399,7 @@ export const azureKeyVaultPkiSyncFactory = ({
|
|||||||
if (existingSyncRecord?.externalIdentifier) {
|
if (existingSyncRecord?.externalIdentifier) {
|
||||||
const existingAzureCert = vaultCertificates[existingSyncRecord.externalIdentifier];
|
const existingAzureCert = vaultCertificates[existingSyncRecord.externalIdentifier];
|
||||||
|
|
||||||
if (existingAzureCert && preserveVersion) {
|
if (existingAzureCert && enableVersioning) {
|
||||||
targetCertName = existingSyncRecord.externalIdentifier;
|
targetCertName = existingSyncRecord.externalIdentifier;
|
||||||
activeExternalIdentifiers.add(targetCertName);
|
activeExternalIdentifiers.add(targetCertName);
|
||||||
|
|
||||||
@@ -409,7 +409,7 @@ export const azureKeyVaultPkiSyncFactory = ({
|
|||||||
}
|
}
|
||||||
} else if (!existingAzureCert) {
|
} else if (!existingAzureCert) {
|
||||||
shouldCreateNew = true;
|
shouldCreateNew = true;
|
||||||
} else if (!preserveVersion) {
|
} else if (!enableVersioning) {
|
||||||
shouldCreateNew = true;
|
shouldCreateNew = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -544,7 +544,7 @@ export const azureKeyVaultPkiSyncFactory = ({
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (preserveVersion) {
|
if (enableVersioning) {
|
||||||
const currentCertificate = await certificateDAL.findById(certificateId);
|
const currentCertificate = await certificateDAL.findById(certificateId);
|
||||||
if (currentCertificate?.renewedFromCertificateId) {
|
if (currentCertificate?.renewedFromCertificateId) {
|
||||||
await certificateSyncDAL.removeCertificates(pkiSync.id, [currentCertificate.renewedFromCertificateId]);
|
await certificateSyncDAL.removeCertificates(pkiSync.id, [currentCertificate.renewedFromCertificateId]);
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ export const AzureKeyVaultPkiSyncConfigSchema = z.object({
|
|||||||
const AzureKeyVaultPkiSyncOptionsSchema = z.object({
|
const AzureKeyVaultPkiSyncOptionsSchema = z.object({
|
||||||
canImportCertificates: z.boolean().default(false),
|
canImportCertificates: z.boolean().default(false),
|
||||||
canRemoveCertificates: z.boolean().default(true),
|
canRemoveCertificates: z.boolean().default(true),
|
||||||
preserveVersion: z.boolean().default(true),
|
enableVersioning: z.boolean().default(true),
|
||||||
certificateNameSchema: z
|
certificateNameSchema: z
|
||||||
.string()
|
.string()
|
||||||
.optional()
|
.optional()
|
||||||
|
|||||||
@@ -95,10 +95,17 @@ export const pkiSyncServiceFactory = ({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const invalidCertificates = certificates.filter((cert) => cert.projectId !== expectedProjectId);
|
const invalidProjectCertificates = certificates.filter((cert) => cert.projectId !== expectedProjectId);
|
||||||
if (invalidCertificates.length > 0) {
|
if (invalidProjectCertificates.length > 0) {
|
||||||
throw new BadRequestError({
|
throw new BadRequestError({
|
||||||
message: `Certificates do not belong to the same project: ${invalidCertificates.map((cert) => cert.id).join(", ")}`
|
message: `Certificates do not belong to the same project: ${invalidProjectCertificates.map((cert) => cert.id).join(", ")}`
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const invalidRenewedCertificates = certificates.filter((cert) => cert.renewedByCertificateId);
|
||||||
|
if (invalidRenewedCertificates.length > 0) {
|
||||||
|
throw new BadRequestError({
|
||||||
|
message: `Cannot add renewed certificates to PKI sync: ${invalidRenewedCertificates.map((cert) => cert.id).join(", ")}`
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ export const PkiSyncConnectionField = ({ onChange: callback }: Props) => {
|
|||||||
<Controller
|
<Controller
|
||||||
render={({ field: { value, onChange }, fieldState: { error } }) => (
|
render={({ field: { value, onChange }, fieldState: { error } }) => (
|
||||||
<FormControl
|
<FormControl
|
||||||
tooltipText="App Connections can be created from the Organization Settings page."
|
tooltipText="App Connections can be created from the Project Settings page."
|
||||||
isError={Boolean(error)}
|
isError={Boolean(error)}
|
||||||
errorText={error?.message}
|
errorText={error?.message}
|
||||||
label={`${connectionName} Connection`}
|
label={`${connectionName} Connection`}
|
||||||
|
|||||||
+2
-2
@@ -141,7 +141,7 @@ export const PkiSyncOptionsFields = ({ destination }: Props) => {
|
|||||||
{currentDestination === PkiSync.AzureKeyVault && (
|
{currentDestination === PkiSync.AzureKeyVault && (
|
||||||
<Controller
|
<Controller
|
||||||
control={control}
|
control={control}
|
||||||
name="syncOptions.preserveVersion"
|
name="syncOptions.enableVersioning"
|
||||||
render={({ field: { value, onChange }, fieldState: { error } }) => (
|
render={({ field: { value, onChange }, fieldState: { error } }) => (
|
||||||
<FormControl isError={Boolean(error)} errorText={error?.message}>
|
<FormControl isError={Boolean(error)} errorText={error?.message}>
|
||||||
<Switch
|
<Switch
|
||||||
@@ -160,7 +160,7 @@ export const PkiSyncOptionsFields = ({ destination }: Props) => {
|
|||||||
<p>
|
<p>
|
||||||
When enabled, Infisical will create a new version of the existing
|
When enabled, Infisical will create a new version of the existing
|
||||||
certificate in Azure Key Vault during certificate renewal syncs,
|
certificate in Azure Key Vault during certificate renewal syncs,
|
||||||
preserving the certificate name.
|
preserving the original certificate name.
|
||||||
</p>
|
</p>
|
||||||
<p className="mt-4">
|
<p className="mt-4">
|
||||||
This allows consuming services to continue using the same certificate name
|
This allows consuming services to continue using the same certificate name
|
||||||
|
|||||||
+1
-1
@@ -7,7 +7,7 @@ import { BasePkiSyncSchema } from "./base-pki-sync-schema";
|
|||||||
const AzureKeyVaultSyncOptionsSchema = z.object({
|
const AzureKeyVaultSyncOptionsSchema = z.object({
|
||||||
canImportCertificates: z.boolean().default(false),
|
canImportCertificates: z.boolean().default(false),
|
||||||
canRemoveCertificates: z.boolean().default(true),
|
canRemoveCertificates: z.boolean().default(true),
|
||||||
preserveVersion: z.boolean().default(true),
|
enableVersioning: z.boolean().default(true),
|
||||||
certificateNameSchema: z
|
certificateNameSchema: z
|
||||||
.string()
|
.string()
|
||||||
.optional()
|
.optional()
|
||||||
|
|||||||
@@ -458,31 +458,33 @@ export const CertificatesTable = ({ handlePopUpOpen }: Props) => {
|
|||||||
</ProjectPermissionCan>
|
</ProjectPermissionCan>
|
||||||
);
|
);
|
||||||
})()}
|
})()}
|
||||||
{/* PKI Sync management - only for active certificates */}
|
{/* PKI Sync management - only for active certificates that are not renewed */}
|
||||||
{certificate.status === CertStatus.ACTIVE && (
|
{certificate.status === CertStatus.ACTIVE &&
|
||||||
<ProjectPermissionCan
|
!certificate.renewedByCertificateId && (
|
||||||
I={ProjectPermissionCertificateActions.Edit}
|
<ProjectPermissionCan
|
||||||
a={ProjectPermissionSub.Certificates}
|
I={ProjectPermissionCertificateActions.Edit}
|
||||||
>
|
a={ProjectPermissionSub.Certificates}
|
||||||
{(isAllowed) => (
|
>
|
||||||
<DropdownMenuItem
|
{(isAllowed) => (
|
||||||
className={twMerge(
|
<DropdownMenuItem
|
||||||
!isAllowed && "pointer-events-none cursor-not-allowed opacity-50"
|
className={twMerge(
|
||||||
)}
|
!isAllowed &&
|
||||||
onClick={async () =>
|
"pointer-events-none cursor-not-allowed opacity-50"
|
||||||
handlePopUpOpen("managePkiSyncs", {
|
)}
|
||||||
certificateId: certificate.id,
|
onClick={async () =>
|
||||||
commonName: certificate.commonName
|
handlePopUpOpen("managePkiSyncs", {
|
||||||
})
|
certificateId: certificate.id,
|
||||||
}
|
commonName: certificate.commonName
|
||||||
disabled={!isAllowed}
|
})
|
||||||
icon={<FontAwesomeIcon icon={faLink} />}
|
}
|
||||||
>
|
disabled={!isAllowed}
|
||||||
Manage PKI Syncs
|
icon={<FontAwesomeIcon icon={faLink} />}
|
||||||
</DropdownMenuItem>
|
>
|
||||||
)}
|
Manage PKI Syncs
|
||||||
</ProjectPermissionCan>
|
</DropdownMenuItem>
|
||||||
)}
|
)}
|
||||||
|
</ProjectPermissionCan>
|
||||||
|
)}
|
||||||
{/* Only show revoke button if CA supports revocation */}
|
{/* Only show revoke button if CA supports revocation */}
|
||||||
{(() => {
|
{(() => {
|
||||||
const caType = caCapabilityMap[certificate.caId];
|
const caType = caCapabilityMap[certificate.caId];
|
||||||
|
|||||||
Reference in New Issue
Block a user