mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 05:27:48 +00:00
Merge pull request #2133 from akhilmhdh/feat/aws-kms-sm
fix: slug too big for project fixed
This commit is contained in:
@@ -39,7 +39,7 @@ export const registerExternalKmsRouter = async (server: FastifyZodProvider) => {
|
|||||||
},
|
},
|
||||||
schema: {
|
schema: {
|
||||||
body: z.object({
|
body: z.object({
|
||||||
slug: z.string().min(1).trim().optional(),
|
slug: z.string().min(1).trim().toLowerCase().optional(),
|
||||||
description: z.string().min(1).trim().optional(),
|
description: z.string().min(1).trim().optional(),
|
||||||
provider: ExternalKmsInputSchema
|
provider: ExternalKmsInputSchema
|
||||||
}),
|
}),
|
||||||
@@ -75,7 +75,7 @@ export const registerExternalKmsRouter = async (server: FastifyZodProvider) => {
|
|||||||
id: z.string().trim().min(1)
|
id: z.string().trim().min(1)
|
||||||
}),
|
}),
|
||||||
body: z.object({
|
body: z.object({
|
||||||
slug: z.string().min(1).trim().optional(),
|
slug: z.string().min(1).trim().toLowerCase().optional(),
|
||||||
description: z.string().min(1).trim().optional(),
|
description: z.string().min(1).trim().optional(),
|
||||||
provider: ExternalKmsInputUpdateSchema
|
provider: ExternalKmsInputUpdateSchema
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ export const externalKmsServiceFactory = ({
|
|||||||
actorOrgId
|
actorOrgId
|
||||||
);
|
);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Edit, OrgPermissionSubjects.Settings);
|
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Edit, OrgPermissionSubjects.Settings);
|
||||||
const kmsSlug = slug ? slugify(slug) : slugify(alphaNumericNanoId(32));
|
const kmsSlug = slug ? slugify(slug) : slugify(alphaNumericNanoId(8).toLowerCase());
|
||||||
|
|
||||||
let sanitizedProviderInput = "";
|
let sanitizedProviderInput = "";
|
||||||
switch (provider.type) {
|
switch (provider.type) {
|
||||||
|
|||||||
@@ -56,15 +56,18 @@ export const kmsServiceFactory = ({
|
|||||||
const cipher = symmetricCipherService(SymmetricEncryption.AES_GCM_256);
|
const cipher = symmetricCipherService(SymmetricEncryption.AES_GCM_256);
|
||||||
const kmsKeyMaterial = randomSecureBytes(32);
|
const kmsKeyMaterial = randomSecureBytes(32);
|
||||||
const encryptedKeyMaterial = cipher.encrypt(kmsKeyMaterial, ROOT_ENCRYPTION_KEY);
|
const encryptedKeyMaterial = cipher.encrypt(kmsKeyMaterial, ROOT_ENCRYPTION_KEY);
|
||||||
const sanitizedSlug = slug ? slugify(slug) : slugify(alphaNumericNanoId(32));
|
const sanitizedSlug = slug ? slugify(slug) : slugify(alphaNumericNanoId(8).toLowerCase());
|
||||||
const dbQuery = async (db: Knex) => {
|
const dbQuery = async (db: Knex) => {
|
||||||
const kmsDoc = await kmsDAL.create({
|
const kmsDoc = await kmsDAL.create(
|
||||||
slug: sanitizedSlug,
|
{
|
||||||
orgId,
|
slug: sanitizedSlug,
|
||||||
isReserved
|
orgId,
|
||||||
});
|
isReserved
|
||||||
|
},
|
||||||
|
db
|
||||||
|
);
|
||||||
|
|
||||||
const { encryptedKey, ...doc } = await internalKmsDAL.create(
|
await internalKmsDAL.create(
|
||||||
{
|
{
|
||||||
version: 1,
|
version: 1,
|
||||||
encryptedKey: encryptedKeyMaterial,
|
encryptedKey: encryptedKeyMaterial,
|
||||||
@@ -73,7 +76,7 @@ export const kmsServiceFactory = ({
|
|||||||
},
|
},
|
||||||
db
|
db
|
||||||
);
|
);
|
||||||
return doc;
|
return kmsDoc;
|
||||||
};
|
};
|
||||||
if (tx) return dbQuery(tx);
|
if (tx) return dbQuery(tx);
|
||||||
const doc = await kmsDAL.transaction(async (tx2) => dbQuery(tx2));
|
const doc = await kmsDAL.transaction(async (tx2) => dbQuery(tx2));
|
||||||
|
|||||||
Reference in New Issue
Block a user