mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-05 14:26:38 +00:00
misc: added credential hash
This commit is contained in:
@@ -116,7 +116,7 @@ export const decryptAsymmetric = ({ ciphertext, nonce, publicKey, privateKey }:
|
|||||||
|
|
||||||
export const generateSymmetricKey = (size = 32) => crypto.randomBytes(size).toString("base64");
|
export const generateSymmetricKey = (size = 32) => crypto.randomBytes(size).toString("base64");
|
||||||
|
|
||||||
export const generateHash = (value: string) => crypto.createHash("sha256").update(value).digest("hex");
|
export const generateHash = (value: string | Buffer) => crypto.createHash("sha256").update(value).digest("hex");
|
||||||
|
|
||||||
export const generateAsymmetricKeyPair = () => {
|
export const generateAsymmetricKeyPair = () => {
|
||||||
const pair = nacl.box.keyPair();
|
const pair = nacl.box.keyPair();
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { TAppConnections } from "@app/db/schemas/app-connections";
|
import { TAppConnections } from "@app/db/schemas/app-connections";
|
||||||
|
import { generateHash } from "@app/lib/crypto/encryption";
|
||||||
import { AppConnection } from "@app/services/app-connection/app-connection-enums";
|
import { AppConnection } from "@app/services/app-connection/app-connection-enums";
|
||||||
import { TAppConnectionServiceFactoryDep } from "@app/services/app-connection/app-connection-service";
|
import { TAppConnectionServiceFactoryDep } from "@app/services/app-connection/app-connection-service";
|
||||||
import { TAppConnection, TAppConnectionConfig } from "@app/services/app-connection/app-connection-types";
|
import { TAppConnection, TAppConnectionConfig } from "@app/services/app-connection/app-connection-types";
|
||||||
@@ -112,6 +113,7 @@ export const decryptAppConnection = async (
|
|||||||
encryptedCredentials: appConnection.encryptedCredentials,
|
encryptedCredentials: appConnection.encryptedCredentials,
|
||||||
orgId: appConnection.orgId,
|
orgId: appConnection.orgId,
|
||||||
kmsService
|
kmsService
|
||||||
})
|
}),
|
||||||
|
credentialsHash: generateHash(appConnection.encryptedCredentials)
|
||||||
} as TAppConnection;
|
} as TAppConnection;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ export const BaseAppConnectionSchema = AppConnectionsSchema.omit({
|
|||||||
encryptedCredentials: true,
|
encryptedCredentials: true,
|
||||||
app: true,
|
app: true,
|
||||||
method: true
|
method: true
|
||||||
|
}).extend({
|
||||||
|
credentialsHash: z.string().optional()
|
||||||
});
|
});
|
||||||
|
|
||||||
export const GenericCreateAppConnectionFieldsSchema = (app: AppConnection) =>
|
export const GenericCreateAppConnectionFieldsSchema = (app: AppConnection) =>
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { ForbiddenError, subject } from "@casl/ability";
|
|||||||
|
|
||||||
import { OrgPermissionAppConnectionActions, OrgPermissionSubjects } from "@app/ee/services/permission/org-permission";
|
import { OrgPermissionAppConnectionActions, OrgPermissionSubjects } from "@app/ee/services/permission/org-permission";
|
||||||
import { TPermissionServiceFactory } from "@app/ee/services/permission/permission-service";
|
import { TPermissionServiceFactory } from "@app/ee/services/permission/permission-service";
|
||||||
|
import { generateHash } from "@app/lib/crypto/encryption";
|
||||||
import { BadRequestError, DatabaseError, NotFoundError } from "@app/lib/errors";
|
import { BadRequestError, DatabaseError, NotFoundError } from "@app/lib/errors";
|
||||||
import { DiscriminativePick, OrgServiceActor } from "@app/lib/types";
|
import { DiscriminativePick, OrgServiceActor } from "@app/lib/types";
|
||||||
import { AppConnection } from "@app/services/app-connection/app-connection-enums";
|
import { AppConnection } from "@app/services/app-connection/app-connection-enums";
|
||||||
@@ -185,6 +186,7 @@ export const appConnectionServiceFactory = ({
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
...connection,
|
...connection,
|
||||||
|
credentialsHash: generateHash(connection.encryptedCredentials),
|
||||||
credentials: validatedCredentials
|
credentials: validatedCredentials
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user