mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 17:27:40 +00:00
feat(rbac): resolved merge conflict
This commit is contained in:
@@ -277,12 +277,20 @@ export const deleteIntegration = async (req: Request, res: Response) => {
|
|||||||
|
|
||||||
// Will trigger sync for all integrations within the given env and workspace id
|
// Will trigger sync for all integrations within the given env and workspace id
|
||||||
export const manualSync = async (req: Request, res: Response) => {
|
export const manualSync = async (req: Request, res: Response) => {
|
||||||
const { workspaceId, environment } = req.body;
|
const {
|
||||||
|
body: { workspaceId, environment }
|
||||||
|
} = await validateRequest(reqValidator.ManualSyncV1, req);
|
||||||
|
|
||||||
|
const { permission } = await getUserProjectPermissions(req.user._id, workspaceId);
|
||||||
|
ForbiddenError.from(permission).throwUnlessCan(
|
||||||
|
ProjectPermissionActions.Edit,
|
||||||
|
ProjectPermissionSub.Integrations
|
||||||
|
);
|
||||||
|
|
||||||
syncSecretsToActiveIntegrationsQueue({
|
syncSecretsToActiveIntegrationsQueue({
|
||||||
workspaceId,
|
workspaceId,
|
||||||
environment
|
environment
|
||||||
})
|
});
|
||||||
|
|
||||||
res.status(200).send()
|
res.status(200).send();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -105,34 +105,46 @@ export const createWorkspaceEnvironment = async (req: Request, res: Response) =>
|
|||||||
* @param res
|
* @param res
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
export const reorderWorkspaceEnvironments = async (
|
export const reorderWorkspaceEnvironments = async (req: Request, res: Response) => {
|
||||||
req: Request,
|
const {
|
||||||
res: Response
|
params: { workspaceId },
|
||||||
) => {
|
body: { environmentName, environmentSlug, otherEnvironmentSlug, otherEnvironmentName }
|
||||||
const { workspaceId } = req.params;
|
} = await validateRequest(reqValidator.ReorderWorkspaceEnvironmentsV2, req);
|
||||||
const { environmentSlug, environmentName, otherEnvironmentSlug, otherEnvironmentName } = req.body;
|
|
||||||
|
const { permission } = await getUserProjectPermissions(req.user._id, workspaceId);
|
||||||
|
ForbiddenError.from(permission).throwUnlessCan(
|
||||||
|
ProjectPermissionActions.Edit,
|
||||||
|
ProjectPermissionSub.Environments
|
||||||
|
);
|
||||||
|
|
||||||
// atomic update the env to avoid conflict
|
// atomic update the env to avoid conflict
|
||||||
const workspace = await Workspace.findById(workspaceId).exec();
|
const workspace = await Workspace.findById(workspaceId).exec();
|
||||||
if (!workspace) {
|
if (!workspace) {
|
||||||
throw BadRequestError({message: "Couldn't load workspace"});
|
throw BadRequestError({ message: "Couldn't load workspace" });
|
||||||
}
|
}
|
||||||
|
|
||||||
const environmentIndex = workspace.environments.findIndex((env) => env.name === environmentName && env.slug === environmentSlug)
|
const environmentIndex = workspace.environments.findIndex(
|
||||||
const otherEnvironmentIndex = workspace.environments.findIndex((env) => env.name === otherEnvironmentName && env.slug === otherEnvironmentSlug)
|
(env) => env.name === environmentName && env.slug === environmentSlug
|
||||||
|
);
|
||||||
|
const otherEnvironmentIndex = workspace.environments.findIndex(
|
||||||
|
(env) => env.name === otherEnvironmentName && env.slug === otherEnvironmentSlug
|
||||||
|
);
|
||||||
|
|
||||||
if (environmentIndex === -1 || otherEnvironmentIndex === -1) {
|
if (environmentIndex === -1 || otherEnvironmentIndex === -1) {
|
||||||
throw BadRequestError({message: "environment or otherEnvironment couldn't be found"})
|
throw BadRequestError({ message: "environment or otherEnvironment couldn't be found" });
|
||||||
}
|
}
|
||||||
|
|
||||||
// swap the order of the environments
|
// swap the order of the environments
|
||||||
[workspace.environments[environmentIndex], workspace.environments[otherEnvironmentIndex]] = [workspace.environments[otherEnvironmentIndex], workspace.environments[environmentIndex]]
|
[workspace.environments[environmentIndex], workspace.environments[otherEnvironmentIndex]] = [
|
||||||
|
workspace.environments[otherEnvironmentIndex],
|
||||||
|
workspace.environments[environmentIndex]
|
||||||
|
];
|
||||||
|
|
||||||
await workspace.save()
|
await workspace.save();
|
||||||
|
|
||||||
return res.status(200).send({
|
return res.status(200).send({
|
||||||
message: "Successfully reordered environments",
|
message: "Successfully reordered environments",
|
||||||
workspace: workspaceId,
|
workspace: workspaceId
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -57,8 +57,7 @@ export const completeAccountSignup = async (req: Request, res: Response) => {
|
|||||||
if (providerAuthToken) {
|
if (providerAuthToken) {
|
||||||
await validateProviderAuthToken({
|
await validateProviderAuthToken({
|
||||||
email,
|
email,
|
||||||
providerAuthToken,
|
providerAuthToken
|
||||||
user
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
const [AUTH_TOKEN_TYPE, AUTH_TOKEN_VALUE] = <[string, string]>(
|
const [AUTH_TOKEN_TYPE, AUTH_TOKEN_VALUE] = <[string, string]>(
|
||||||
|
|||||||
@@ -1,27 +1,15 @@
|
|||||||
import express from "express";
|
import express from "express";
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
import {
|
import { requireAuth } from "../../../middleware";
|
||||||
requireSecretSnapshotAuth,
|
import { AuthMode } from "../../../variables";
|
||||||
} from "../../middleware";
|
|
||||||
import {
|
|
||||||
requireAuth,
|
|
||||||
validateRequest,
|
|
||||||
} from "../../../middleware";
|
|
||||||
import { param } from "express-validator";
|
|
||||||
import { ADMIN, AuthMode, MEMBER } from "../../../variables";
|
|
||||||
import { secretSnapshotController } from "../../controllers/v1";
|
import { secretSnapshotController } from "../../controllers/v1";
|
||||||
|
|
||||||
router.get(
|
router.get(
|
||||||
"/:secretSnapshotId",
|
"/:secretSnapshotId",
|
||||||
requireAuth({
|
requireAuth({
|
||||||
acceptedAuthModes: [AuthMode.JWT],
|
acceptedAuthModes: [AuthMode.JWT]
|
||||||
}),
|
}),
|
||||||
requireSecretSnapshotAuth({
|
secretSnapshotController.getSecretSnapshot
|
||||||
acceptedRoles: [ADMIN, MEMBER],
|
|
||||||
}),
|
|
||||||
param("secretSnapshotId").exists().trim(),
|
|
||||||
validateRequest,
|
|
||||||
secretSnapshotController.getSecretSnapshot
|
|
||||||
);
|
);
|
||||||
|
|
||||||
export default router;
|
export default router;
|
||||||
@@ -1,8 +1,6 @@
|
|||||||
import express from "express";
|
import express from "express";
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
import {
|
import { requireAuth } from "../../middleware";
|
||||||
requireAuth
|
|
||||||
} from "../../middleware";
|
|
||||||
import { AuthMode } from "../../variables";
|
import { AuthMode } from "../../variables";
|
||||||
import { integrationController } from "../../controllers/v1";
|
import { integrationController } from "../../controllers/v1";
|
||||||
|
|
||||||
|
|||||||
@@ -23,18 +23,8 @@ router.put(
|
|||||||
router.patch(
|
router.patch(
|
||||||
"/:workspaceId/environments",
|
"/:workspaceId/environments",
|
||||||
requireAuth({
|
requireAuth({
|
||||||
acceptedAuthModes: [AuthMode.JWT, AuthMode.API_KEY],
|
acceptedAuthModes: [AuthMode.JWT, AuthMode.API_KEY]
|
||||||
}),
|
}),
|
||||||
requireWorkspaceAuth({
|
|
||||||
acceptedRoles: [ADMIN, MEMBER],
|
|
||||||
locationWorkspaceId: "params",
|
|
||||||
}),
|
|
||||||
param("workspaceId").exists().trim(),
|
|
||||||
body("environmentSlug").exists().isString().trim(),
|
|
||||||
body("environmentName").exists().isString().trim(),
|
|
||||||
body("otherEnvironmentSlug").exists().isString().trim(),
|
|
||||||
body("otherEnvironmentName").exists().isString().trim(),
|
|
||||||
validateRequest,
|
|
||||||
environmentController.reorderWorkspaceEnvironments
|
environmentController.reorderWorkspaceEnvironments
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -35,3 +35,15 @@ export const GetAllAccessibileEnvironmentsOfWorkspaceV2 = z.object({
|
|||||||
workspaceId: z.string().trim()
|
workspaceId: z.string().trim()
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const ReorderWorkspaceEnvironmentsV2 = z.object({
|
||||||
|
params: z.object({
|
||||||
|
workspaceId: z.string().trim()
|
||||||
|
}),
|
||||||
|
body: z.object({
|
||||||
|
environmentSlug: z.string().trim(),
|
||||||
|
environmentName: z.string().trim(),
|
||||||
|
otherEnvironmentSlug: z.string().trim(),
|
||||||
|
otherEnvironmentName: z.string().trim()
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|||||||
@@ -99,3 +99,10 @@ export const DeleteIntegrationV1 = z.object({
|
|||||||
integrationId: z.string().trim()
|
integrationId: z.string().trim()
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const ManualSyncV1 = z.object({
|
||||||
|
body: z.object({
|
||||||
|
environment: z.string(),
|
||||||
|
workspaceId: z.string()
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|||||||
@@ -12,11 +12,10 @@ type Props = {
|
|||||||
const ProjectPermissionContext = createContext<null | TProjectPermission>(null);
|
const ProjectPermissionContext = createContext<null | TProjectPermission>(null);
|
||||||
|
|
||||||
export const ProjectPermissionProvider = ({ children }: Props): JSX.Element => {
|
export const ProjectPermissionProvider = ({ children }: Props): JSX.Element => {
|
||||||
const { currentWorkspace } = useWorkspace();
|
const { currentWorkspace, isLoading: isWsLoading } = useWorkspace();
|
||||||
const workspaceId = currentWorkspace?._id || "";
|
const workspaceId = currentWorkspace?._id || "";
|
||||||
const { data: permission, isLoading } = useGetUserProjectPermissions({ workspaceId });
|
const { data: permission, isLoading } = useGetUserProjectPermissions({ workspaceId });
|
||||||
|
|
||||||
console.log(workspaceId);
|
|
||||||
if (!permission && currentWorkspace) {
|
if (!permission && currentWorkspace) {
|
||||||
return (
|
return (
|
||||||
<div className="flex items-center justify-center w-screen h-screen bg-bunker-800">
|
<div className="flex items-center justify-center w-screen h-screen bg-bunker-800">
|
||||||
@@ -25,7 +24,7 @@ export const ProjectPermissionProvider = ({ children }: Props): JSX.Element => {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isLoading && workspaceId) {
|
if ((isLoading && currentWorkspace) || isWsLoading) {
|
||||||
return (
|
return (
|
||||||
<div className="flex items-center justify-center w-screen h-screen bg-bunker-800">
|
<div className="flex items-center justify-center w-screen h-screen bg-bunker-800">
|
||||||
<img
|
<img
|
||||||
|
|||||||
@@ -56,7 +56,13 @@ import {
|
|||||||
UpgradePlanModal
|
UpgradePlanModal
|
||||||
} from "@app/components/v2";
|
} from "@app/components/v2";
|
||||||
import { leaveConfirmDefaultMessage } from "@app/const";
|
import { leaveConfirmDefaultMessage } from "@app/const";
|
||||||
import { ProjectPermissionActions, ProjectPermissionSub,useOrganization, useSubscription, useWorkspace } from "@app/context";
|
import {
|
||||||
|
ProjectPermissionActions,
|
||||||
|
ProjectPermissionSub,
|
||||||
|
useOrganization,
|
||||||
|
useSubscription,
|
||||||
|
useWorkspace
|
||||||
|
} from "@app/context";
|
||||||
import { withProjectPermission } from "@app/hoc";
|
import { withProjectPermission } from "@app/hoc";
|
||||||
import { useLeaveConfirm, usePopUp, useToggle } from "@app/hooks";
|
import { useLeaveConfirm, usePopUp, useToggle } from "@app/hooks";
|
||||||
import {
|
import {
|
||||||
@@ -522,11 +528,12 @@ export const DashboardPage = withProjectPermission(
|
|||||||
);
|
);
|
||||||
|
|
||||||
const onCreateWsTag = useCallback(
|
const onCreateWsTag = useCallback(
|
||||||
async (tagName: string) => {
|
async (tagName: string, tagColor: string) => {
|
||||||
try {
|
try {
|
||||||
await createWsTag({
|
await createWsTag({
|
||||||
workspaceID: workspaceId,
|
workspaceID: workspaceId,
|
||||||
tagName,
|
tagName,
|
||||||
|
tagColor,
|
||||||
tagSlug: tagName.replace(" ", "_")
|
tagSlug: tagName.replace(" ", "_")
|
||||||
});
|
});
|
||||||
handlePopUpClose("addTag");
|
handlePopUpClose("addTag");
|
||||||
@@ -862,7 +869,7 @@ export const DashboardPage = withProjectPermission(
|
|||||||
}}
|
}}
|
||||||
leftIcon={<FontAwesomeIcon icon={faCodeCommit} />}
|
leftIcon={<FontAwesomeIcon icon={faCodeCommit} />}
|
||||||
isLoading={isLoadingSnapshotCount}
|
isLoading={isLoadingSnapshotCount}
|
||||||
isDisabled={!canDoRollback || !isAllowed}
|
isDisabled={!canDoRollback && !isAllowed}
|
||||||
className="h-10"
|
className="h-10"
|
||||||
>
|
>
|
||||||
{snapshotCount} Commits
|
{snapshotCount} Commits
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import { zodResolver } from "@hookform/resolvers/zod";
|
|||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
|
||||||
import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider";
|
import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider";
|
||||||
import { OrgPermissionCan, ProjectPermissionCan } from "@app/components/permissions";
|
import { ProjectPermissionCan } from "@app/components/permissions";
|
||||||
import {
|
import {
|
||||||
decryptAssymmetric,
|
decryptAssymmetric,
|
||||||
encryptAssymmetric
|
encryptAssymmetric
|
||||||
@@ -34,8 +34,6 @@ import {
|
|||||||
UpgradePlanModal
|
UpgradePlanModal
|
||||||
} from "@app/components/v2";
|
} from "@app/components/v2";
|
||||||
import {
|
import {
|
||||||
GeneralPermissionActions,
|
|
||||||
OrgPermissionSubjects,
|
|
||||||
ProjectPermissionActions,
|
ProjectPermissionActions,
|
||||||
ProjectPermissionSub,
|
ProjectPermissionSub,
|
||||||
useOrganization,
|
useOrganization,
|
||||||
|
|||||||
Reference in New Issue
Block a user