mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-06 14:27:59 +00:00
fix: provider -> configuration
This commit is contained in:
@@ -9,6 +9,7 @@ import {
|
|||||||
TExternalKmsInputSchema,
|
TExternalKmsInputSchema,
|
||||||
TExternalKmsInputUpdateSchema
|
TExternalKmsInputUpdateSchema
|
||||||
} from "@app/ee/services/external-kms/providers/model";
|
} from "@app/ee/services/external-kms/providers/model";
|
||||||
|
import { BadRequestError } from "@app/lib/errors";
|
||||||
import { readLimit, writeLimit } from "@app/server/config/rateLimiter";
|
import { readLimit, writeLimit } from "@app/server/config/rateLimiter";
|
||||||
import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
|
import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
|
||||||
import { AuthMode } from "@app/services/auth/auth-type";
|
import { AuthMode } from "@app/services/auth/auth-type";
|
||||||
@@ -75,7 +76,9 @@ export const registerExternalKmsEndpoints = <
|
|||||||
|
|
||||||
// Validate that the KMS is of the expected provider type
|
// Validate that the KMS is of the expected provider type
|
||||||
if (externalKms.external.provider !== provider) {
|
if (externalKms.external.provider !== provider) {
|
||||||
throw new Error(`KMS provider mismatch. Expected ${provider}, got ${externalKms.external.provider}`);
|
throw new BadRequestError({
|
||||||
|
message: `KMS provider mismatch. Expected ${provider}, got ${externalKms.external.provider}`
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
await server.services.auditLog.createAuditLog({
|
await server.services.auditLog.createAuditLog({
|
||||||
@@ -104,7 +107,7 @@ export const registerExternalKmsEndpoints = <
|
|||||||
body: z.object({
|
body: z.object({
|
||||||
name: z.string().min(1).trim().toLowerCase(),
|
name: z.string().min(1).trim().toLowerCase(),
|
||||||
description: z.string().trim().optional(),
|
description: z.string().trim().optional(),
|
||||||
provider: createSchema
|
configuration: createSchema
|
||||||
}),
|
}),
|
||||||
response: {
|
response: {
|
||||||
200: z.object({
|
200: z.object({
|
||||||
@@ -114,19 +117,15 @@ export const registerExternalKmsEndpoints = <
|
|||||||
},
|
},
|
||||||
onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
|
onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
|
||||||
handler: async (req) => {
|
handler: async (req) => {
|
||||||
const {
|
const { name, description, configuration } = req.body as {
|
||||||
name,
|
|
||||||
description,
|
|
||||||
provider: providerInputs
|
|
||||||
} = req.body as {
|
|
||||||
name: string;
|
name: string;
|
||||||
description?: string;
|
description?: string;
|
||||||
provider: T["inputs"];
|
configuration: T["inputs"];
|
||||||
};
|
};
|
||||||
|
|
||||||
const providerInput = {
|
const providerInput = {
|
||||||
type: provider,
|
type: provider,
|
||||||
inputs: providerInputs
|
inputs: configuration
|
||||||
} as TExternalKmsInputSchema;
|
} as TExternalKmsInputSchema;
|
||||||
|
|
||||||
const externalKms = await server.services.externalKms.create({
|
const externalKms = await server.services.externalKms.create({
|
||||||
@@ -170,7 +169,7 @@ export const registerExternalKmsEndpoints = <
|
|||||||
body: z.object({
|
body: z.object({
|
||||||
name: z.string().min(1).trim().toLowerCase().optional(),
|
name: z.string().min(1).trim().toLowerCase().optional(),
|
||||||
description: z.string().trim().optional(),
|
description: z.string().trim().optional(),
|
||||||
provider: updateSchema
|
configuration: updateSchema
|
||||||
}),
|
}),
|
||||||
response: {
|
response: {
|
||||||
200: z.object({
|
200: z.object({
|
||||||
@@ -180,19 +179,15 @@ export const registerExternalKmsEndpoints = <
|
|||||||
},
|
},
|
||||||
onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
|
onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
|
||||||
handler: async (req) => {
|
handler: async (req) => {
|
||||||
const {
|
const { name, description, configuration } = req.body as {
|
||||||
name,
|
|
||||||
description,
|
|
||||||
provider: providerInputs
|
|
||||||
} = req.body as {
|
|
||||||
name?: string;
|
name?: string;
|
||||||
description?: string;
|
description?: string;
|
||||||
provider: Partial<T["inputs"]>;
|
configuration: Partial<T["inputs"]>;
|
||||||
};
|
};
|
||||||
|
|
||||||
const providerInput = {
|
const providerInput = {
|
||||||
type: provider,
|
type: provider,
|
||||||
inputs: providerInputs
|
inputs: configuration
|
||||||
} as TExternalKmsInputUpdateSchema;
|
} as TExternalKmsInputUpdateSchema;
|
||||||
|
|
||||||
const externalKms = await server.services.externalKms.updateById({
|
const externalKms = await server.services.externalKms.updateById({
|
||||||
@@ -252,7 +247,9 @@ export const registerExternalKmsEndpoints = <
|
|||||||
|
|
||||||
// Validate that the KMS is of the expected provider type
|
// Validate that the KMS is of the expected provider type
|
||||||
if (externalKms.external.provider !== provider) {
|
if (externalKms.external.provider !== provider) {
|
||||||
throw new Error(`KMS provider mismatch. Expected ${provider}, got ${externalKms.external.provider}`);
|
throw new BadRequestError({
|
||||||
|
message: `KMS provider mismatch. Expected ${provider}, got ${externalKms.external.provider}`
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
await server.services.auditLog.createAuditLog({
|
await server.services.auditLog.createAuditLog({
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ export const useAddExternalKms = (orgId: string) => {
|
|||||||
const { data } = await apiRequest.post(`/api/v1/external-kms/${providerPath}`, {
|
const { data } = await apiRequest.post(`/api/v1/external-kms/${providerPath}`, {
|
||||||
name,
|
name,
|
||||||
description,
|
description,
|
||||||
provider: provider.inputs
|
configuration: provider.inputs
|
||||||
});
|
});
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
@@ -46,7 +46,7 @@ export const useUpdateExternalKms = (orgId: string) => {
|
|||||||
const { data } = await apiRequest.patch(`/api/v1/external-kms/${providerPath}/${kmsId}`, {
|
const { data } = await apiRequest.patch(`/api/v1/external-kms/${providerPath}/${kmsId}`, {
|
||||||
name,
|
name,
|
||||||
description,
|
description,
|
||||||
provider: provider.inputs
|
configuration: provider.inputs
|
||||||
});
|
});
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
|
|||||||
Reference in New Issue
Block a user