mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-02 20:25:47 +00:00
Fix service tokens not working after upgrade
This commit is contained in:
@@ -33,11 +33,12 @@ export const assignWorkspaceKeysToMembers = ({ members, decryptKey, userPrivateK
|
|||||||
type TCreateProjectKeyDTO = {
|
type TCreateProjectKeyDTO = {
|
||||||
publicKey: string;
|
publicKey: string;
|
||||||
privateKey: string;
|
privateKey: string;
|
||||||
|
plainProjectKey?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const createProjectKey = ({ publicKey, privateKey }: TCreateProjectKeyDTO) => {
|
export const createProjectKey = ({ publicKey, privateKey, plainProjectKey }: TCreateProjectKeyDTO) => {
|
||||||
// 3. Create a random key that we'll use as the project key.
|
// 3. Create a random key that we'll use as the project key.
|
||||||
const randomBytes = crypto.randomBytes(16).toString("hex");
|
const randomBytes = plainProjectKey || crypto.randomBytes(16).toString("hex");
|
||||||
|
|
||||||
// 4. Encrypt the project key with the users key pair.
|
// 4. Encrypt the project key with the users key pair.
|
||||||
const { ciphertext: encryptedProjectKey, nonce: encryptedProjectKeyIv } = encryptAsymmetric(
|
const { ciphertext: encryptedProjectKey, nonce: encryptedProjectKeyIv } = encryptAsymmetric(
|
||||||
|
|||||||
@@ -122,6 +122,13 @@ export const projectQueueFactory = ({
|
|||||||
tag: data.encryptedPrivateKey.encryptedKeyTag
|
tag: data.encryptedPrivateKey.encryptedKeyTag
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const decryptedPlainProjectKey = decryptAsymmetric({
|
||||||
|
ciphertext: oldProjectKey.encryptedKey,
|
||||||
|
nonce: oldProjectKey.nonce,
|
||||||
|
publicKey: oldProjectKey.sender.publicKey,
|
||||||
|
privateKey: userPrivateKey
|
||||||
|
});
|
||||||
|
|
||||||
const projectEnvs = await projectEnvDAL.find({
|
const projectEnvs = await projectEnvDAL.find({
|
||||||
projectId: project.id
|
projectId: project.id
|
||||||
});
|
});
|
||||||
@@ -199,6 +206,7 @@ export const projectQueueFactory = ({
|
|||||||
|
|
||||||
// Create a project key
|
// Create a project key
|
||||||
const { key: newEncryptedProjectKey, iv: newEncryptedProjectKeyIv } = createProjectKey({
|
const { key: newEncryptedProjectKey, iv: newEncryptedProjectKeyIv } = createProjectKey({
|
||||||
|
plainProjectKey: decryptedPlainProjectKey,
|
||||||
publicKey: ghostUser.keys.publicKey,
|
publicKey: ghostUser.keys.publicKey,
|
||||||
privateKey: ghostUser.keys.plainPrivateKey
|
privateKey: ghostUser.keys.plainPrivateKey
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user