Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

fix(kmip): address PR review feedback

bernie-ge2cff17c0ec9
diff --git a/backend/src/db/migrations/20260603120000_kmip-server-resource-auth.ts b/backend/src/db/migrations/20260603120000_kmip-server-resource-auth.ts
index 3c9d7f02ee..f5a8363404 100644
--- a/backend/src/db/migrations/20260603120000_kmip-server-resource-auth.ts
+++ b/backend/src/db/migrations/20260603120000_kmip-server-resource-auth.ts
@@ -17,7 +17,6 @@ export async function up(knex: Knex): Promise<void> {
t.foreign("orgId").references("id").inTable(TableName.Organization).onDelete("CASCADE");
t.string("name").notNullable();
- t.datetime("heartbeat");
t.integer("tokenVersion").notNullable().defaultTo(0);
t.unique(["orgId", "name"]);
diff --git a/backend/src/db/schemas/kmip-servers.ts b/backend/src/db/schemas/kmip-servers.ts
index 56f62ca75f..a8e46c9e5f 100644
--- a/backend/src/db/schemas/kmip-servers.ts
+++ b/backend/src/db/schemas/kmip-servers.ts
@@ -13,7 +13,6 @@ export const KmipServersSchema = z.object({
updatedAt: z.date(),
orgId: z.string().uuid(),
name: z.string(),
- heartbeat: z.date().nullable().optional(),
tokenVersion: z.number().default(0),
hostnamesOrIps: z.string().nullable().optional(),
ttl: z.string().nullable().optional(),
diff --git a/backend/src/ee/routes/v1/kmip-server-router.ts b/backend/src/ee/routes/v1/kmip-server-router.ts
index 8061003908..fe1c24b67e 100644
--- a/backend/src/ee/routes/v1/kmip-server-router.ts
+++ b/backend/src/ee/routes/v1/kmip-server-router.ts
@@ -22,8 +22,7 @@ const SanitizedKmipServerSchema = KmipServersSchema.pick({
ttl: true,
keyAlgorithm: true,
createdAt: true,
- updatedAt: true,
- heartbeat: true
+ updatedAt: true
}).extend({
canRevoke: z.boolean()
});
diff --git a/backend/src/ee/services/kmip-server/kmip-server-service.ts b/backend/src/ee/services/kmip-server/kmip-server-service.ts
index 13fd64172f..88be01e83c 100644
--- a/backend/src/ee/services/kmip-server/kmip-server-service.ts
+++ b/backend/src/ee/services/kmip-server/kmip-server-service.ts
@@ -91,7 +91,8 @@ export const kmipServerServiceFactory = ({
throw new NotFoundError({ message: `KMIP server ${kmipServerId} not found` });
}
- return kmipServerDAL.updateById(kmipServerId, fields);
+ const definedFields = Object.fromEntries(Object.entries(fields).filter(([, v]) => v !== undefined));
+ return kmipServerDAL.updateById(kmipServerId, definedFields);
};
const getOrgKmipServer = async ({ kmipServerId, orgId }: { kmipServerId: string; orgId: string }) => {
diff --git a/backend/src/ee/services/kmip/kmip-service.ts b/backend/src/ee/services/kmip/kmip-service.ts
index d40ca41e32..2e4b29de1c 100644
--- a/backend/src/ee/services/kmip/kmip-service.ts
+++ b/backend/src/ee/services/kmip/kmip-service.ts
@@ -800,11 +800,8 @@ export const kmipServiceFactory = ({
};
};
- // The /kmip/spec/* endpoints identify the acting client from caller-supplied headers, so before
- // trusting them assert the presented certificates are ones this org actually issued: the server
- // cert must exist in the org, and the client cert serial must belong to the named client and be
- // unexpired. This stops a KMIP server access token from impersonating an arbitrary client by
- // supplying forged headers.
+ // Validates that the presented certs were actually issued by this org.
+ // Revocation checking is out of scope until KMIP certs gain a revocation model.
const validateKmipSessionCertificates = async ({
orgId,
kmipClientId,
diff --git a/backend/src/ee/services/resource-auth-method/resource-auth-method-service.ts b/backend/src/ee/services/resource-auth-method/resource-auth-method-service.ts
index fdb2e7b3db..5a8deedfab 100644
--- a/backend/src/ee/services/resource-auth-method/resource-auth-method-service.ts
+++ b/backend/src/ee/services/resource-auth-method/resource-auth-method-service.ts
@@ -131,7 +131,7 @@ export const resourceAuthMethodServiceFactory = ({
};
// Bumps tokenVersion (invalidating outstanding JWTs) and clears heartbeat. Gateways
- // additionally clear heartbeatTTL; relays and KMIP servers don't carry that column.
+ // additionally clear heartbeatTTL; KMIP servers have neither heartbeat column.
const $bumpTokenVersion = async (resource: ResourceRef, tx?: Knex): Promise<number> => {
if (resource.type === RESOURCE_TYPE_GATEWAY) {
const refreshed = await gatewayV2DAL.updateById(
@@ -145,7 +145,7 @@ export const resourceAuthMethodServiceFactory = ({
const refreshed = await relayDAL.updateById(resource.id, { $incr: { tokenVersion: 1 }, heartbeat: null }, tx);
return refreshed.tokenVersion;
}
- const refreshed = await kmipServerDAL.updateById(resource.id, { $incr: { tokenVersion: 1 }, heartbeat: null }, tx);
+ const refreshed = await kmipServerDAL.updateById(resource.id, { $incr: { tokenVersion: 1 } }, tx);
return refreshed.tokenVersion;
};
diff --git a/frontend/src/hooks/api/kmipServers/types.ts b/frontend/src/hooks/api/kmipServers/types.ts
index cec15033d3..32334cfb65 100644
--- a/frontend/src/hooks/api/kmipServers/types.ts
+++ b/frontend/src/hooks/api/kmipServers/types.ts
@@ -27,7 +27,6 @@ export type TKmipServer = {
updatedAt: string;
orgId: string;
name: string;
- heartbeat: string | null;
hostnamesOrIps: string | null;
ttl: string | null;
keyAlgorithm: string | null;
diff --git a/frontend/src/pages/organization/KmipServersPage/KmipServerDetailsByIDPage/KmipServerDetailsByIDPage.tsx b/frontend/src/pages/organization/KmipServersPage/KmipServerDetailsByIDPage/KmipServerDetailsByIDPage.tsx
index 487af21c0e..d485b18930 100644
--- a/frontend/src/pages/organization/KmipServersPage/KmipServerDetailsByIDPage/KmipServerDetailsByIDPage.tsx
+++ b/frontend/src/pages/organization/KmipServersPage/KmipServerDetailsByIDPage/KmipServerDetailsByIDPage.tsx
@@ -54,7 +54,6 @@ const Page = () => {
kmipServerId={kmipServerId}
kmipServerName={kmipServer.name}
authMethod={kmipServer.authMethod}
- isFirstTimeSetup={!kmipServer.heartbeat}
/>
<KmipServerClientsSection />
</div>
diff --git a/frontend/src/pages/organization/KmipServersPage/KmipServerDetailsByIDPage/components/KmipServerDeploySection/KmipServerDeploySection.tsx b/frontend/src/pages/organization/KmipServersPage/KmipServerDetailsByIDPage/components/KmipServerDeploySection/KmipServerDeploySection.tsx
index e2b726cb74..5102f5e30c 100644
--- a/frontend/src/pages/organization/KmipServersPage/KmipServerDetailsByIDPage/components/KmipServerDeploySection/KmipServerDeploySection.tsx
+++ b/frontend/src/pages/organization/KmipServersPage/KmipServerDetailsByIDPage/components/KmipServerDeploySection/KmipServerDeploySection.tsx
@@ -11,7 +11,7 @@ import {
CardHeader,
CardTitle
} from "@app/components/v3";
-import { useOrganization } from "@app/context";
+
import {
OrgKmipServerPermissionActions,
OrgPermissionSubjects
@@ -25,16 +25,14 @@ type Props = {
kmipServerId: string;
kmipServerName: string;
authMethod: TKmipServerAuthMethodView;
- isFirstTimeSetup: boolean;
};
export const KmipServerDeploySection = ({
kmipServerId,
kmipServerName,
- authMethod,
- isFirstTimeSetup
+ authMethod
}: Props) => {
- const { isSubOrganization } = useOrganization();
+
const [showDialog, setShowDialog] = useState(false);
const [enrollmentToken, setEnrollmentToken] = useState<string | null>(null);
const { mutateAsync: mint, isPending: isMinting } = useGenerateKmipServerEnrollmentToken();
@@ -67,11 +65,9 @@ export const KmipServerDeploySection = ({
a={OrgPermissionSubjects.KmipServer}
>
{(isAllowed) => {
- let variant: "neutral" | "org" | "sub-org" = "neutral";
- if (isFirstTimeSetup) variant = isSubOrganization ? "sub-org" : "org";
return (
<Button
- variant={variant}
+ variant="neutral"
size="sm"
isPending={isMinting}
isDisabled={!isAllowed || isMinting}