Skip to content

Commit

Permalink
Merge pull request #1446 from Infisical/daniel/ghost-users-fixes
Browse files Browse the repository at this point in the history
(Fix): Project upgrade
  • Loading branch information
maidul98 authored Feb 22, 2024
2 parents 4251e95 + 028541a commit 3d82a43
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -419,10 +419,6 @@ export const projectMembershipServiceFactory = ({
});
}

if (project.version === ProjectVersion.V1) {
throw new BadRequestError({ message: "Please upgrade your project on your dashboard" });
}

const projectMembers = await projectMembershipDAL.findMembershipsByEmail(projectId, emails);

if (projectMembers.length !== emails.length) {
Expand Down
5 changes: 3 additions & 2 deletions backend/src/services/project/project-fns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,12 @@ export const assignWorkspaceKeysToMembers = ({ members, decryptKey, userPrivateK
type TCreateProjectKeyDTO = {
publicKey: 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.
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.
const { ciphertext: encryptedProjectKey, nonce: encryptedProjectKeyIv } = encryptAsymmetric(
Expand Down
8 changes: 8 additions & 0 deletions backend/src/services/project/project-queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,13 @@ export const projectQueueFactory = ({
tag: data.encryptedPrivateKey.encryptedKeyTag
});

const decryptedPlainProjectKey = decryptAsymmetric({
ciphertext: oldProjectKey.encryptedKey,
nonce: oldProjectKey.nonce,
publicKey: oldProjectKey.sender.publicKey,
privateKey: userPrivateKey
});

const projectEnvs = await projectEnvDAL.find({
projectId: project.id
});
Expand Down Expand Up @@ -199,6 +206,7 @@ export const projectQueueFactory = ({

// Create a project key
const { key: newEncryptedProjectKey, iv: newEncryptedProjectKeyIv } = createProjectKey({
plainProjectKey: decryptedPlainProjectKey,
publicKey: ghostUser.keys.publicKey,
privateKey: ghostUser.keys.plainPrivateKey
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---
title: "Create Workspace"
title: "Create Project"
openapi: "POST /api/v2/workspace"
---
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: "Delete Workspace"
title: "Delete Project"
openapi: "DELETE /api/v1/workspace/{workspaceId}"
---

Expand Down
2 changes: 1 addition & 1 deletion docs/api-reference/endpoints/workspaces/get-workspace.mdx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---
title: "Get Workspace"
title: "Get Project"
openapi: "GET /api/v1/workspace/{workspaceId}"
---
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---
title: "Update Workspace"
title: "Update Project"
openapi: "PATCH /api/v1/workspace/{workspaceId}"
---
113 changes: 59 additions & 54 deletions frontend/src/views/SecretOverviewPage/SecretOverviewPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
Tooltip,
Tr
} from "@app/components/v2";
// import { UpgradeProjectAlert } from "@app/components/v2/UpgradeProjectAlert";
import { UpgradeProjectAlert } from "@app/components/v2/UpgradeProjectAlert";
import { useOrganization, useWorkspace } from "@app/context";
import {
useCreateFolder,
Expand All @@ -40,8 +40,8 @@ import {
useGetUserWsKey,
useUpdateSecretV3
} from "@app/hooks/api";
import { ProjectVersion } from "@app/hooks/api/workspace/types";

// import { ProjectVersion } from "@app/hooks/api/workspace/types";
import { FolderBreadCrumbs } from "./components/FolderBreadCrumbs";
import { ProjectIndexSecretsSection } from "./components/ProjectIndexSecretsSection";
import { SecretOverviewFolderRow } from "./components/SecretOverviewFolderRow";
Expand Down Expand Up @@ -274,60 +274,65 @@ export const SecretOverviewPage = () => {
<div className="relative right-5 ml-4">
<NavHeader pageName={t("dashboard.title")} isProjectRelated />
</div>
<div className="mt-6">
<p className="text-3xl font-semibold text-bunker-100">Secrets Overview</p>
<p className="text-md text-bunker-300">
Inject your secrets using
<a
className="ml-1 text-mineshaft-300 underline decoration-primary-800 underline-offset-4 duration-200 hover:text-mineshaft-100 hover:decoration-primary-600"
href="https://infisical.com/docs/cli/overview"
target="_blank"
rel="noopener noreferrer"
>
Infisical CLI
</a>
,
<a
className="ml-1 text-mineshaft-300 underline decoration-primary-800 underline-offset-4 duration-200 hover:text-mineshaft-100 hover:decoration-primary-600"
href="https://infisical.com/docs/documentation/getting-started/api"
target="_blank"
rel="noopener noreferrer"
>
Infisical API
</a>
,
<a
className="ml-1 text-mineshaft-300 underline decoration-primary-800 underline-offset-4 duration-200 hover:text-mineshaft-100 hover:decoration-primary-600"
href="https://infisical.com/docs/sdks/overview"
target="_blank"
rel="noopener noreferrer"
>
Infisical SDKs
</a>
, and
<a
className="ml-1 text-mineshaft-300 underline decoration-primary-800 underline-offset-4 duration-200 hover:text-mineshaft-100 hover:decoration-primary-600"
href="https://infisical.com/docs/documentation/getting-started/introduction"
target="_blank"
rel="noopener noreferrer"
>
more
</a>
.
</p>
</div>
<div className="space-y-8">
<div className="mt-6">
<p className="text-3xl font-semibold text-bunker-100">Secrets Overview</p>
<p className="text-md text-bunker-300">
Inject your secrets using
<a
className="ml-1 text-mineshaft-300 underline decoration-primary-800 underline-offset-4 duration-200 hover:text-mineshaft-100 hover:decoration-primary-600"
href="https://infisical.com/docs/cli/overview"
target="_blank"
rel="noopener noreferrer"
>
Infisical CLI
</a>
,
<a
className="ml-1 text-mineshaft-300 underline decoration-primary-800 underline-offset-4 duration-200 hover:text-mineshaft-100 hover:decoration-primary-600"
href="https://infisical.com/docs/documentation/getting-started/api"
target="_blank"
rel="noopener noreferrer"
>
Infisical API
</a>
,
<a
className="ml-1 text-mineshaft-300 underline decoration-primary-800 underline-offset-4 duration-200 hover:text-mineshaft-100 hover:decoration-primary-600"
href="https://infisical.com/docs/sdks/overview"
target="_blank"
rel="noopener noreferrer"
>
Infisical SDKs
</a>
, and
<a
className="ml-1 text-mineshaft-300 underline decoration-primary-800 underline-offset-4 duration-200 hover:text-mineshaft-100 hover:decoration-primary-600"
href="https://infisical.com/docs/documentation/getting-started/introduction"
target="_blank"
rel="noopener noreferrer"
>
more
</a>
.
</p>
</div>

{currentWorkspace?.version === ProjectVersion.V1 && (
<UpgradeProjectAlert project={currentWorkspace} />
)}

<div className="mt-8 flex items-center justify-between">
<FolderBreadCrumbs secretPath={secretPath} onResetSearch={handleResetSearch} />
<div className="w-80">
<Input
className="h-[2.3rem] bg-mineshaft-800 placeholder-mineshaft-50 duration-200 focus:bg-mineshaft-700/80"
placeholder="Search by secret/folder name..."
value={searchFilter}
onChange={(e) => setSearchFilter(e.target.value)}
leftIcon={<FontAwesomeIcon icon={faMagnifyingGlass} />}
/>
<div className="flex items-center justify-between">
<FolderBreadCrumbs secretPath={secretPath} onResetSearch={handleResetSearch} />
<div className="w-80">
<Input
className="h-[2.3rem] bg-mineshaft-800 placeholder-mineshaft-50 duration-200 focus:bg-mineshaft-700/80"
placeholder="Search by secret/folder name..."
value={searchFilter}
onChange={(e) => setSearchFilter(e.target.value)}
leftIcon={<FontAwesomeIcon icon={faMagnifyingGlass} />}
/>
</div>
</div>
</div>
<div className="thin-scrollbar mt-4" ref={parentTableRef}>
Expand Down

0 comments on commit 3d82a43

Please sign in to comment.