Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

revoke tokens (untested)

Matheus Nogueira860b2cdaeb85
diff --git a/backend/src/ee/routes/v1/honey-token-router.ts b/backend/src/ee/routes/v1/honey-token-router.ts
index 98a667a206..158a0bd233 100644
--- a/backend/src/ee/routes/v1/honey-token-router.ts
+++ b/backend/src/ee/routes/v1/honey-token-router.ts
@@ -206,8 +206,8 @@ export const registerHoneyTokenRouter = async (server: FastifyZodProvider) => {
});
server.route({
- url: "/:honeyTokenId",
- method: "DELETE",
+ url: "/:honeyTokenId/revoke",
+ method: "POST",
config: {
rateLimit: writeLimit
},
@@ -226,7 +226,7 @@ export const registerHoneyTokenRouter = async (server: FastifyZodProvider) => {
}
},
handler: async (req) => {
- const { honeyTokenId } = await server.services.honeyTokenCrud.deleteHoneyToken(
+ const { honeyTokenId } = await server.services.honeyTokenCrud.revokeHoneyToken(
{
honeyTokenId: req.params.honeyTokenId,
projectId: req.body.projectId
diff --git a/backend/src/ee/services/honey-token/honey-token-enums.ts b/backend/src/ee/services/honey-token/honey-token-enums.ts
index 67c89cd058..84181e6ace 100644
--- a/backend/src/ee/services/honey-token/honey-token-enums.ts
+++ b/backend/src/ee/services/honey-token/honey-token-enums.ts
@@ -4,7 +4,8 @@ export enum HoneyTokenType {
export enum HoneyTokenStatus {
Active = "active",
- Triggered = "triggered"
+ Triggered = "triggered",
+ Revoked = "revoked"
}
export enum HoneyTokenEventType {
diff --git a/backend/src/ee/services/honey-token/honey-token-service.ts b/backend/src/ee/services/honey-token/honey-token-service.ts
index bd57fe7e0a..fc16a01ecf 100644
--- a/backend/src/ee/services/honey-token/honey-token-service.ts
+++ b/backend/src/ee/services/honey-token/honey-token-service.ts
@@ -459,7 +459,7 @@ export const honeyTokenServiceFactory = ({
};
};
- const deleteHoneyToken = async (
+ const revokeHoneyToken = async (
{ honeyTokenId, projectId }: { honeyTokenId: string; projectId: string },
actor: OrgServiceActor
) => {
@@ -467,7 +467,7 @@ export const honeyTokenServiceFactory = ({
if (!plan.honeyTokens) {
throw new BadRequestError({
- message: "Failed to delete honey token due to plan restriction. Upgrade plan to use honey tokens."
+ message: "Failed to revoke honey token due to plan restriction. Upgrade plan to use honey tokens."
});
}
@@ -488,6 +488,10 @@ export const honeyTokenServiceFactory = ({
throw new NotFoundError({ message: `Honey token with ID "${honeyTokenId}" not found` });
}
+ if (honeyToken.status === HoneyTokenStatus.Revoked) {
+ throw new BadRequestError({ message: "Honey token is already revoked" });
+ }
+
const { decryptor } = await kmsService.createCipherPairWithDataKey({
type: KmsDataKey.Organization,
orgId: actor.orgId
@@ -536,7 +540,11 @@ export const honeyTokenServiceFactory = ({
secretVersionDAL
});
- await honeyTokenDAL.deleteById(honeyTokenId);
+ await honeyTokenDAL.updateById(honeyTokenId, {
+ status: HoneyTokenStatus.Revoked,
+ revokedAt: new Date(),
+ revokedByUserId: actor.id
+ });
await secretDAL.invalidateSecretCacheByProjectId(projectId);
await snapshotService.performSnapshot(honeyToken.folderId);
@@ -814,7 +822,7 @@ export const honeyTokenServiceFactory = ({
return {
create,
updateHoneyToken,
- deleteHoneyToken,
+ revokeHoneyToken,
resetHoneyToken,
getCredentials,
getHoneyTokenById,
diff --git a/frontend/src/components/honey-tokens/RevokeHoneyTokenModal.tsx b/frontend/src/components/honey-tokens/RevokeHoneyTokenModal.tsx
new file mode 100644
index 0000000000..72598e44b2
--- /dev/null
+++ b/frontend/src/components/honey-tokens/RevokeHoneyTokenModal.tsx
@@ -0,0 +1,99 @@
+import { useEffect, useState } from "react";
+import { BanIcon } from "lucide-react";
+
+import { createNotification } from "@app/components/notifications";
+import {
+ AlertDialog,
+ AlertDialogAction,
+ AlertDialogCancel,
+ AlertDialogContent,
+ AlertDialogDescription,
+ AlertDialogFooter,
+ AlertDialogHeader,
+ AlertDialogMedia,
+ AlertDialogTitle,
+ Field,
+ FieldContent,
+ FieldLabel,
+ Input
+} from "@app/components/v3";
+import { useRevokeHoneyToken } from "@app/hooks/api/honeyTokens";
+import { TDashboardHoneyToken } from "@app/hooks/api/honeyTokens/types";
+
+type Props = {
+ honeyToken?: TDashboardHoneyToken;
+ isOpen: boolean;
+ onOpenChange: (isOpen: boolean) => void;
+};
+
+export const RevokeHoneyTokenModal = ({ isOpen, onOpenChange, honeyToken }: Props) => {
+ const revokeHoneyToken = useRevokeHoneyToken();
+ const [inputData, setInputData] = useState("");
+
+ useEffect(() => {
+ setInputData("");
+ }, [isOpen]);
+
+ if (!honeyToken) return null;
+
+ const handleRevoke = async () => {
+ await revokeHoneyToken.mutateAsync({
+ honeyTokenId: honeyToken.id,
+ projectId: honeyToken.projectId
+ });
+
+ createNotification({
+ text: `Successfully revoked honey token "${honeyToken.name}"`,
+ type: "success"
+ });
+
+ onOpenChange(false);
+ };
+
+ return (
+ <AlertDialog open={isOpen} onOpenChange={onOpenChange}>
+ <AlertDialogContent className="sm:max-w-xl!">
+ <AlertDialogHeader>
+ <AlertDialogMedia>
+ <BanIcon />
+ </AlertDialogMedia>
+ <AlertDialogTitle>Are you sure you want to revoke {honeyToken.name}?</AlertDialogTitle>
+ <AlertDialogDescription>
+ This will revoke the AWS IAM credentials and remove the associated decoy secrets from
+ this environment. The honey token record and its events will be preserved for audit
+ purposes.
+ </AlertDialogDescription>
+ </AlertDialogHeader>
+ <form
+ onSubmit={(e) => {
+ e.preventDefault();
+ if (inputData === honeyToken.name) handleRevoke();
+ }}
+ >
+ <Field>
+ <FieldLabel>
+ Type <span className="font-bold">{honeyToken.name}</span> to confirm
+ </FieldLabel>
+ <FieldContent>
+ <Input
+ value={inputData}
+ onChange={(e) => setInputData(e.target.value)}
+ placeholder={`Type ${honeyToken.name} here`}
+ />
+ </FieldContent>
+ </Field>
+ </form>
+ <AlertDialogFooter>
+ <AlertDialogCancel>Cancel</AlertDialogCancel>
+ <AlertDialogAction
+ variant="danger"
+ onClick={handleRevoke}
+ disabled={inputData !== honeyToken.name}
+ >
+ Revoke
+ </AlertDialogAction>
+ </AlertDialogFooter>
+ </AlertDialogContent>
+ </AlertDialog>
+ );
+};
diff --git a/frontend/src/components/honey-tokens/index.ts b/frontend/src/components/honey-tokens/index.ts
index 28679b5883..32bf385bd3 100644
--- a/frontend/src/components/honey-tokens/index.ts
+++ b/frontend/src/components/honey-tokens/index.ts
@@ -1,4 +1,4 @@
export * from "./CreateHoneyTokenModal";
-export * from "./DeleteHoneyTokenModal";
export * from "./EditHoneyTokenModal";
+export * from "./RevokeHoneyTokenModal";
export * from "./ViewHoneyTokenCredentialsModal";
diff --git a/frontend/src/hooks/api/honeyTokens/enums.ts b/frontend/src/hooks/api/honeyTokens/enums.ts
index 2bcf67306e..d8d03c853b 100644
--- a/frontend/src/hooks/api/honeyTokens/enums.ts
+++ b/frontend/src/hooks/api/honeyTokens/enums.ts
@@ -4,5 +4,6 @@ export enum HoneyTokenType {
export enum HoneyTokenStatus {
Active = "active",
- Triggered = "triggered"
+ Triggered = "triggered",
+ Revoked = "revoked"
}
diff --git a/frontend/src/hooks/api/honeyTokens/mutations.tsx b/frontend/src/hooks/api/honeyTokens/mutations.tsx
index 293a10b781..b03581b42a 100644
--- a/frontend/src/hooks/api/honeyTokens/mutations.tsx
+++ b/frontend/src/hooks/api/honeyTokens/mutations.tsx
@@ -5,8 +5,8 @@ import { dashboardKeys } from "@app/hooks/api/dashboard/queries";
import {
TCreateHoneyTokenDTO,
- TDeleteHoneyTokenDTO,
THoneyToken,
+ TRevokeHoneyTokenDTO,
TUpdateHoneyTokenDTO
} from "./types";
@@ -64,14 +64,14 @@ export const useResetHoneyToken = () => {
});
};
-export const useDeleteHoneyToken = () => {
+export const useRevokeHoneyToken = () => {
const queryClient = useQueryClient();
- return useMutation<{ honeyTokenId: string }, object, TDeleteHoneyTokenDTO>({
+ return useMutation<{ honeyTokenId: string }, object, TRevokeHoneyTokenDTO>({
mutationFn: async ({ honeyTokenId, projectId }) => {
- const { data } = await apiRequest.delete<{ honeyTokenId: string }>(
- `/api/v1/honey-tokens/${honeyTokenId}`,
- { data: { projectId } }
+ const { data } = await apiRequest.post<{ honeyTokenId: string }>(
+ `/api/v1/honey-tokens/${honeyTokenId}/revoke`,
+ { projectId }
);
return data;
},
diff --git a/frontend/src/hooks/api/honeyTokens/types/index.ts b/frontend/src/hooks/api/honeyTokens/types/index.ts
index b6bf72398d..13a89231e9 100644
--- a/frontend/src/hooks/api/honeyTokens/types/index.ts
+++ b/frontend/src/hooks/api/honeyTokens/types/index.ts
@@ -46,6 +46,11 @@ export type TDeleteHoneyTokenDTO = {
projectId: string;
};
+export type TRevokeHoneyTokenDTO = {
+ honeyTokenId: string;
+ projectId: string;
+};
+
export {
type TAwsHoneyToken,
type TAwsHoneyTokenCredentialsResponse,
diff --git a/frontend/src/pages/secret-manager/HoneyTokenDetailsByIDPage/HoneyTokenDetailsByIDPage.tsx b/frontend/src/pages/secret-manager/HoneyTokenDetailsByIDPage/HoneyTokenDetailsByIDPage.tsx
index fc71c741d2..1d3e090422 100644
--- a/frontend/src/pages/secret-manager/HoneyTokenDetailsByIDPage/HoneyTokenDetailsByIDPage.tsx
+++ b/frontend/src/pages/secret-manager/HoneyTokenDetailsByIDPage/HoneyTokenDetailsByIDPage.tsx
@@ -4,15 +4,16 @@ import { useNavigate, useParams } from "@tanstack/react-router";
import { format, formatDistanceToNow } from "date-fns";
import {
AlertTriangle,
+ BanIcon,
CalendarIcon,
ChevronLeftIcon,
ClockIcon,
KeyIcon,
MapPinIcon,
RotateCcw,
- SirenIcon,
- Trash2Icon
+ SirenIcon
} from "lucide-react";
+import { twMerge } from "tailwind-merge";
import { createNotification } from "@app/components/notifications";
import { ProjectPermissionCan } from "@app/components/permissions";
@@ -47,7 +48,7 @@ import { ProjectPermissionSub } from "@app/context";
import { ProjectPermissionSecretActions } from "@app/context/ProjectPermissionContext/types";
import { HONEY_TOKEN_CREDENTIAL_FIELDS, HONEY_TOKEN_MAP } from "@app/helpers/honeyTokens";
import { HoneyTokenStatus, HoneyTokenType } from "@app/hooks/api/honeyTokens/enums";
-import { useDeleteHoneyToken, useResetHoneyToken } from "@app/hooks/api/honeyTokens/mutations";
+import { useResetHoneyToken, useRevokeHoneyToken } from "@app/hooks/api/honeyTokens/mutations";
import {
useGetHoneyTokenById,
useGetHoneyTokenCredentials
@@ -68,10 +69,10 @@ const PageContent = () => {
});
const { mutateAsync: resetHoneyToken } = useResetHoneyToken();
- const { mutateAsync: deleteHoneyToken } = useDeleteHoneyToken();
- const [isDeleteOpen, setIsDeleteOpen] = useState(false);
+ const { mutateAsync: revokeHoneyToken } = useRevokeHoneyToken();
+ const [isRevokeOpen, setIsRevokeOpen] = useState(false);
const [isResetOpen, setIsResetOpen] = useState(false);
- const [deleteInput, setDeleteInput] = useState("");
+ const [revokeInput, setRevokeInput] = useState("");
const { data: credentials, isPending: isCredentialsPending } = useGetHoneyTokenCredentials({
honeyTokenId,
projectId,
@@ -79,8 +80,8 @@ const PageContent = () => {
});
useEffect(() => {
- setDeleteInput("");
- }, [isDeleteOpen]);
+ setRevokeInput("");
+ }, [isRevokeOpen]);
if (isPending) {
return (
@@ -103,8 +104,19 @@ const PageContent = () => {
}
const isTriggered = honeyToken.status === HoneyTokenStatus.Triggered;
+ const isRevoked = honeyToken.status === HoneyTokenStatus.Revoked;
const tokenInfo = HONEY_TOKEN_MAP[honeyToken.type as HoneyTokenType];
+ let statusBadgeVariant: "danger" | "neutral" | "success" = "success";
+ let statusLabel = "Active";
+ if (isTriggered) {
+ statusBadgeVariant = "danger";
+ statusLabel = "Triggered";
+ } else if (isRevoked) {
+ statusBadgeVariant = "neutral";
+ statusLabel = "Revoked";
+ }
+
const handleReset = async () => {
await resetHoneyToken({
honeyTokenId: honeyToken.id,
@@ -116,19 +128,15 @@ const PageContent = () => {
});
};
- const handleDelete = async () => {
- await deleteHoneyToken({
+ const handleRevoke = async () => {
+ await revokeHoneyToken({
honeyTokenId: honeyToken.id,
projectId
});
createNotification({
- text: `Successfully deleted honey token "${honeyToken.name}"`,
+ text: `Successfully revoked honey token "${honeyToken.name}"`,
type: "success"
});
- navigate({
- to: ROUTE_PATHS.SecretManager.OverviewPage.path,
- params: { orgId, projectId }
- });
};
return (
@@ -156,16 +164,20 @@ const PageContent = () => {
<div className="flex items-center gap-3">
<div className="flex h-11 w-11 items-center justify-center rounded-lg border border-mineshaft-600 bg-mineshaft-800">
<SirenIcon
- className={isTriggered ? "text-red-500" : "text-yellow-500"}
+ className={twMerge(
+ isTriggered && "text-red-500",
+ isRevoked && "text-mineshaft-400",
+ !isTriggered && !isRevoked && "text-yellow-500"
+ )}
size={22}
/>
</div>
<div className="min-w-0">
<div className="flex items-center gap-2.5">
<p className="truncate text-lg font-medium text-white">{honeyToken.name}</p>
- <Badge variant={isTriggered ? "danger" : "success"}>
+ <Badge variant={statusBadgeVariant}>
{isTriggered && <AlertTriangle size={12} className="mr-1" />}
- {isTriggered ? "Triggered" : "Active"}
+ {statusLabel}
</Badge>
{tokenInfo && (
<Badge variant="neutral" className="flex items-center gap-1">
@@ -190,10 +202,12 @@ const PageContent = () => {
Reset
</Button>
)}
- <Button variant="danger" size="xs" onClick={() => setIsDeleteOpen(true)}>
- <Trash2Icon size={14} />
- Delete
- </Button>
+ {!isRevoked && (
+ <Button variant="danger" size="xs" onClick={() => setIsRevokeOpen(true)}>
+ <BanIcon size={14} />
+ Revoke
+ </Button>
+ )}
</div>
</div>
@@ -235,46 +249,61 @@ const PageContent = () => {
</div>
</div>
- <ProjectPermissionCan
- I={ProjectPermissionSecretActions.DescribeAndReadValue}
- a={ProjectPermissionSub.Secrets}
- >
- {(isAllowed) =>
- isAllowed && (
- <div className="mt-4 border-t border-mineshaft-600 pt-4">
- <div className="mb-2 flex items-center gap-1.5 text-xs text-bunker-300">
- <KeyIcon size={13} />
- <span>Credentials</span>
- </div>
- {isCredentialsPending && (
- <div className="flex flex-col gap-2 py-2">
- <Skeleton className="h-8 w-full rounded-md" />
- <Skeleton className="h-8 w-full rounded-md" />
+ {!isRevoked && (
+ <ProjectPermissionCan
+ I={ProjectPermissionSecretActions.DescribeAndReadValue}
+ a={ProjectPermissionSub.Secrets}
+ >
+ {(isAllowed) =>
+ isAllowed && (
+ <div className="mt-4 border-t border-mineshaft-600 pt-4">
+ <div className="mb-2 flex items-center gap-1.5 text-xs text-bunker-300">
+ <KeyIcon size={13} />
+ <span>Credentials</span>
</div>
- )}
- {!isCredentialsPending && credentials && (
- <div className="flex flex-col gap-x-8 gap-y-2 rounded-sm border border-mineshaft-600 bg-mineshaft-700 p-2">
- {(
- HONEY_TOKEN_CREDENTIAL_FIELDS[honeyToken.type as HoneyTokenType] ?? []
- ).map(({ key, label }) => {
- const mapping = honeyToken.secretsMapping as Record<string, string>;
- const secretName = mapping[key];
- const value = secretName ? credentials[secretName] : undefined;
- return (
- <CredentialDisplay key={key} label={label} isSensitive>
- {value}
- </CredentialDisplay>
- );
- })}
- </div>
- )}
- {!isCredentialsPending && !credentials && (
- <p className="text-xs text-bunker-400">No credentials available.</p>
- )}
- </div>
- )
- }
- </ProjectPermissionCan>
+ {isCredentialsPending && (
+ <div className="flex flex-col gap-2 py-2">
+ <Skeleton className="h-8 w-full rounded-md" />
+ <Skeleton className="h-8 w-full rounded-md" />
+ </div>
+ )}
+ {!isCredentialsPending && credentials && (
+ <div className="flex flex-col gap-x-8 gap-y-2 rounded-sm border border-mineshaft-600 bg-mineshaft-700 p-2">
+ {(
+ HONEY_TOKEN_CREDENTIAL_FIELDS[honeyToken.type as HoneyTokenType] ?? []
+ ).map(({ key, label }) => {
+ const mapping = honeyToken.secretsMapping as Record<string, string>;
+ const secretName = mapping[key];
+ const value = secretName ? credentials[secretName] : undefined;
+ return (
+ <CredentialDisplay key={key} label={label} isSensitive>
+ {value}
+ </CredentialDisplay>
+ );
+ })}
+ </div>
+ )}
+ {!isCredentialsPending && !credentials && (
+ <p className="text-xs text-bunker-400">No credentials available.</p>
+ )}
+ </div>
+ )
+ }
+ </ProjectPermissionCan>
+ )}
+
+ {isRevoked && (
+ <div className="mt-4 rounded-md border border-mineshaft-600 bg-mineshaft-800 p-4">
+ <div className="mb-2 flex items-center gap-2">
+ <BanIcon size={16} className="text-mineshaft-400" />
+ <p className="text-sm font-medium text-mineshaft-300">Honey token revoked</p>
+ </div>
+ <p className="text-xs text-bunker-300">
+ The AWS IAM credentials have been revoked and the decoy secrets removed. The honey
+ token record and its events are preserved for audit purposes.
+ </p>
+ </div>
+ )}
{isTriggered && (
<div className="mt-4 rounded-md border border-yellow-800/50 bg-yellow-900/20 p-4">
@@ -344,22 +373,23 @@ const PageContent = () => {
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
- <AlertDialog open={isDeleteOpen} onOpenChange={setIsDeleteOpen}>
+ <AlertDialog open={isRevokeOpen} onOpenChange={setIsRevokeOpen}>
<AlertDialogContent className="sm:max-w-xl!">
<AlertDialogHeader>
<AlertDialogMedia>
- <Trash2Icon />
+ <BanIcon />
</AlertDialogMedia>
- <AlertDialogTitle>Are you sure you want to delete {honeyToken.name}?</AlertDialogTitle>
+ <AlertDialogTitle>Are you sure you want to revoke {honeyToken.name}?</AlertDialogTitle>
<AlertDialogDescription>
This will revoke the AWS IAM credentials and remove the associated decoy secrets from
- this environment.
+ this environment. The honey token record and its events will be preserved for audit
+ purposes.
</AlertDialogDescription>
</AlertDialogHeader>
<form
onSubmit={(e) => {
e.preventDefault();
- if (deleteInput === honeyToken.name) handleDelete();
+ if (revokeInput === honeyToken.name) handleRevoke();
}}
>
<Field>
@@ -368,8 +398,8 @@ const PageContent = () => {
</FieldLabel>
<FieldContent>
<Input
- value={deleteInput}
- onChange={(e) => setDeleteInput(e.target.value)}
+ value={revokeInput}
+ onChange={(e) => setRevokeInput(e.target.value)}
placeholder={`Type ${honeyToken.name} here`}
/>
</FieldContent>
@@ -379,10 +409,10 @@ const PageContent = () => {
<AlertDialogCancel>Cancel</AlertDialogCancel>
<AlertDialogAction
variant="danger"
- onClick={handleDelete}
- disabled={deleteInput !== honeyToken.name}
+ onClick={handleRevoke}
+ disabled={revokeInput !== honeyToken.name}
>
- Delete
+ Revoke
</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
diff --git a/frontend/src/pages/secret-manager/OverviewPage/OverviewPage.tsx b/frontend/src/pages/secret-manager/OverviewPage/OverviewPage.tsx
index adf9a7d06b..2dc5a6d82f 100644
--- a/frontend/src/pages/secret-manager/OverviewPage/OverviewPage.tsx
+++ b/frontend/src/pages/secret-manager/OverviewPage/OverviewPage.tsx
@@ -24,16 +24,16 @@ import {
} from "lucide-react";
import { twMerge } from "tailwind-merge";
-import { CreateHoneyTokenModal } from "@app/components/honey-tokens";
-import { UpgradePlanModal } from "@app/components/license/UpgradePlanModal";
-import { createNotification } from "@app/components/notifications";
-import { ProjectPermissionCan } from "@app/components/permissions";
-import { CreateSecretRotationV2Modal } from "@app/components/secret-rotations-v2";
import {
- DeleteHoneyTokenModal,
+ CreateHoneyTokenModal,
EditHoneyTokenModal,
+ RevokeHoneyTokenModal,
ViewHoneyTokenCredentialsModal
} from "@app/components/honey-tokens";
+import { UpgradePlanModal } from "@app/components/license/UpgradePlanModal";
+import { createNotification } from "@app/components/notifications";
+import { ProjectPermissionCan } from "@app/components/permissions";
+import { CreateSecretRotationV2Modal } from "@app/components/secret-rotations-v2";
import { DeleteSecretRotationV2Modal } from "@app/components/secret-rotations-v2/DeleteSecretRotationV2Modal";
import { EditSecretRotationV2Modal } from "@app/components/secret-rotations-v2/EditSecretRotationV2Modal";
import { ReconcileLocalAccountRotationModal } from "@app/components/secret-rotations-v2/ReconcileLocalAccountRotationModal";
@@ -146,6 +146,7 @@ import { DashboardSecretsOrderBy, ProjectSecretsImportedBy } from "@app/hooks/ap
import { TDynamicSecret } from "@app/hooks/api/dynamicSecret/types";
import { useGetFolderCommitsCount } from "@app/hooks/api/folderCommits";
import { OrderByDirection } from "@app/hooks/api/generic/types";
+import { TDashboardHoneyToken } from "@app/hooks/api/honeyTokens/types";
import {
useGetExternalMigrationConfigs,
useImportDopplerSecrets,
@@ -163,7 +164,6 @@ import {
SecretRotation as SecretRotationV2,
TSecretRotationV2
} from "@app/hooks/api/secretRotationsV2";
-import { TDashboardHoneyToken } from "@app/hooks/api/honeyTokens/types";
import { useCreateCommit } from "@app/hooks/api/secrets/mutations";
import { fetchProjectSecrets, secretKeys } from "@app/hooks/api/secrets/queries";
import {
@@ -783,7 +783,7 @@ const OverviewPageContent = () => {
"importFromDoppler",
"confirmDisableBatchMode",
"editHoneyToken",
- "deleteHoneyToken",
+ "revokeHoneyToken",
"viewHoneyTokenCredentials"
] as const);
@@ -3088,11 +3088,9 @@ const OverviewPageContent = () => {
getHoneyTokenByName={getHoneyTokenByName}
tableWidth={tableWidth}
key={`overview-ht-${honeyTokenName}-${index + 1}`}
- onEdit={(honeyToken) =>
- handlePopUpOpen("editHoneyToken", honeyToken)
- }
- onDelete={(honeyToken) =>
- handlePopUpOpen("deleteHoneyToken", honeyToken)
+ onEdit={(honeyToken) => handlePopUpOpen("editHoneyToken", honeyToken)}
+ onRevoke={(honeyToken) =>
+ handlePopUpOpen("revokeHoneyToken", honeyToken)
}
onViewCredentials={(honeyToken) =>
handlePopUpOpen("viewHoneyTokenCredentials", honeyToken)
@@ -3441,10 +3439,10 @@ const OverviewPageContent = () => {
honeyToken={popUp.editHoneyToken.data as TDashboardHoneyToken}
onOpenChange={(isOpen) => handlePopUpToggle("editHoneyToken", isOpen)}
/>
- <DeleteHoneyTokenModal
- isOpen={popUp.deleteHoneyToken.isOpen}
- honeyToken={popUp.deleteHoneyToken.data as TDashboardHoneyToken}
- onOpenChange={(isOpen) => handlePopUpToggle("deleteHoneyToken", isOpen)}
+ <RevokeHoneyTokenModal
+ isOpen={popUp.revokeHoneyToken.isOpen}
+ honeyToken={popUp.revokeHoneyToken.data as TDashboardHoneyToken}
+ onOpenChange={(isOpen) => handlePopUpToggle("revokeHoneyToken", isOpen)}
/>
<ViewHoneyTokenCredentialsModal
isOpen={popUp.viewHoneyTokenCredentials.isOpen}
diff --git a/frontend/src/pages/secret-manager/OverviewPage/components/HoneyTokenTableRow/HoneyTokenTableRow.tsx b/frontend/src/pages/secret-manager/OverviewPage/components/HoneyTokenTableRow/HoneyTokenTableRow.tsx
index 5360964550..21b89171a8 100644
--- a/frontend/src/pages/secret-manager/OverviewPage/components/HoneyTokenTableRow/HoneyTokenTableRow.tsx
+++ b/frontend/src/pages/secret-manager/OverviewPage/components/HoneyTokenTableRow/HoneyTokenTableRow.tsx
@@ -1,12 +1,12 @@
import { useNavigate, useParams } from "@tanstack/react-router";
import {
AsteriskIcon,
+ BanIcon,
ChevronDownIcon,
EditIcon,
ExternalLinkIcon,
InfoIcon,
- SirenIcon,
- TrashIcon
+ SirenIcon
} from "lucide-react";
import { twMerge } from "tailwind-merge";
@@ -36,6 +36,12 @@ import { TDashboardHoneyToken } from "@app/hooks/api/honeyTokens/types";
import { ResourceEnvironmentStatusCell } from "../ResourceEnvironmentStatusCell";
+const STATUS_BADGE_VARIANT: Record<string, "success" | "danger" | "neutral"> = {
+ [HoneyTokenStatus.Active]: "success",
+ [HoneyTokenStatus.Triggered]: "danger",
+ [HoneyTokenStatus.Revoked]: "neutral"
+};
+
type Props = {
honeyTokenName: string;
environments: { name: string; slug: string }[];
@@ -43,7 +49,7 @@ type Props = {
getHoneyTokenByName: (slug: string, name: string) => TDashboardHoneyToken | undefined;
tableWidth: number;
onEdit: (honeyToken: TDashboardHoneyToken) => void;
- onDelete: (honeyToken: TDashboardHoneyToken) => void;
+ onRevoke: (honeyToken: TDashboardHoneyToken) => void;
onViewCredentials: (honeyToken: TDashboardHoneyToken) => void;
};
@@ -54,7 +60,7 @@ export const HoneyTokenTableRow = ({
getHoneyTokenByName,
tableWidth,
onEdit,
- onDelete,
+ onRevoke,
onViewCredentials
}: Props) => {
const navigate = useNavigate();
@@ -76,6 +82,11 @@ export const HoneyTokenTableRow = ({
return ht?.status === HoneyTokenStatus.Triggered;
});
+ const isAllRevoked = environments.every((env) => {
+ const ht = getHoneyTokenByName(env.slug, honeyTokenName);
+ return !ht || ht.status === HoneyTokenStatus.Revoked;
+ });
+
const renderActionButtons = (honeyToken: TDashboardHoneyToken) => {
return (
<div
@@ -147,27 +158,29 @@ export const HoneyTokenTableRow = ({
</Tooltip>
)}
</ProjectPermissionCan>
- <ProjectPermissionCan
- I={ProjectPermissionSecretActions.Delete}
- a={ProjectPermissionSub.Secrets}
- >
- {(isAllowed) => (
- <Tooltip>
- <TooltipTrigger>
- <IconButton
- variant="ghost"
- size="xs"
- className="w-0 overflow-hidden border-0 transition-all duration-300 group-hover:w-7 hover:text-danger"
- onClick={() => onDelete(honeyToken)}
- isDisabled={!isAllowed}
- >
- <TrashIcon />
- </IconButton>
- </TooltipTrigger>
- <TooltipContent>Delete</TooltipContent>
- </Tooltip>
- )}
- </ProjectPermissionCan>
+ {honeyToken.status !== HoneyTokenStatus.Revoked && (
+ <ProjectPermissionCan
+ I={ProjectPermissionSecretActions.Delete}
+ a={ProjectPermissionSub.Secrets}
+ >
+ {(isAllowed) => (
+ <Tooltip>
+ <TooltipTrigger>
+ <IconButton
+ variant="ghost"
+ size="xs"
+ className="w-0 overflow-hidden border-0 transition-all duration-300 group-hover:w-7 hover:text-danger"
+ onClick={() => onRevoke(honeyToken)}
+ isDisabled={!isAllowed}
+ >
+ <BanIcon />
+ </IconButton>
+ </TooltipTrigger>
+ <TooltipContent>Revoke</TooltipContent>
+ </Tooltip>
+ )}
+ </ProjectPermissionCan>
+ )}
</div>
);
};
@@ -188,11 +201,10 @@ export const HoneyTokenTableRow = ({
{tokenInfo.name} Honey Token
</Badge>
)}
- <Badge
- variant={honeyToken.status === HoneyTokenStatus.Active ? "success" : "danger"}
- className="mx-1"
- >
- {honeyToken.status === HoneyTokenStatus.Active ? "Active" : "Triggered"}
+ <Badge variant={STATUS_BADGE_VARIANT[honeyToken.status] ?? "neutral"} className="mx-1">
+ {honeyToken.status === HoneyTokenStatus.Active && "Active"}
+ {honeyToken.status === HoneyTokenStatus.Triggered && "Triggered"}
+ {honeyToken.status === HoneyTokenStatus.Revoked && "Revoked"}
</Badge>
{mappedKeys.length > 0 && (
<Tooltip>
@@ -222,7 +234,13 @@ export const HoneyTokenTableRow = ({
{!isSingleEnvView && isExpanded ? (
<ChevronDownIcon />
) : (
- <SirenIcon className={isTriggered ? "text-red" : "text-yellow"} />
+ <SirenIcon
+ className={twMerge(
+ isTriggered && "text-red",
+ !isTriggered && !isAllRevoked && "text-yellow",
+ isAllRevoked && "text-mineshaft-400"
+ )}
+ />
)}
</TableCell>
<TableCell
@@ -249,7 +267,7 @@ export const HoneyTokenTableRow = ({
</div>
</div>
) : (
- <>{honeyTokenName}</>
+ honeyTokenName
)}
</TableCell>
{environments.length > 1 &&
diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/HoneyTokenListView/HoneyTokenItem.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/HoneyTokenListView/HoneyTokenItem.tsx
index a55ac6a84c..3d4ffcf36c 100644
--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/HoneyTokenListView/HoneyTokenItem.tsx
+++ b/frontend/src/pages/secret-manager/SecretDashboardPage/components/HoneyTokenListView/HoneyTokenItem.tsx
@@ -3,11 +3,11 @@ import { useNavigate, useParams } from "@tanstack/react-router";
import { AnimatePresence, motion } from "framer-motion";
import {
AsteriskIcon,
+ BanIcon,
ExternalLinkIcon,
InfoIcon,
PencilIcon,
- SirenIcon,
- Trash2Icon
+ SirenIcon
} from "lucide-react";
import { twMerge } from "tailwind-merge";
@@ -23,11 +23,11 @@ import { TDashboardHoneyToken } from "@app/hooks/api/honeyTokens/types";
type Props = {
honeyToken: TDashboardHoneyToken;
onEdit: () => void;
- onDelete: () => void;
+ onRevoke: () => void;
onViewCredentials: () => void;
};
-export const HoneyTokenItem = ({ honeyToken, onEdit, onDelete, onViewCredentials }: Props) => {
+export const HoneyTokenItem = ({ honeyToken, onEdit, onRevoke, onViewCredentials }: Props) => {
const navigate = useNavigate();
const { orgId, projectId } = useParams({
from: ROUTE_PATHS.SecretManager.SecretDashboardPage.id
@@ -38,6 +38,12 @@ export const HoneyTokenItem = ({ honeyToken, onEdit, onDelete, onViewCredentials
const honeyTokenInfo = HONEY_TOKEN_MAP[type as HoneyTokenType];
const mappedSecretKeys = Object.values(secretsMapping || {});
+ const statusVariantMap: Record<string, "success" | "danger" | "neutral"> = {
+ [HoneyTokenStatus.Active]: "success",
+ [HoneyTokenStatus.Triggered]: "danger",
+ [HoneyTokenStatus.Revoked]: "neutral"
+ };
+
return (
<>
<div
@@ -59,7 +65,9 @@ export const HoneyTokenItem = ({ honeyToken, onEdit, onDelete, onViewCredentials
<div
className={twMerge(
"flex w-11 items-center py-2 pl-5",
- status === HoneyTokenStatus.Triggered ? "text-red" : "text-yellow"
+ status === HoneyTokenStatus.Triggered && "text-red",
+ status === HoneyTokenStatus.Active && "text-yellow",
+ status === HoneyTokenStatus.Revoked && "text-mineshaft-400"
)}
>
<SirenIcon className="size-4" />
@@ -77,8 +85,10 @@ export const HoneyTokenItem = ({ honeyToken, onEdit, onDelete, onViewCredentials
{honeyTokenInfo.name} Honey Token
</Badge>
)}
- <Badge variant={status === HoneyTokenStatus.Active ? "success" : "danger"}>
- {status === HoneyTokenStatus.Active ? "Active" : "Triggered"}
+ <Badge variant={statusVariantMap[status] ?? "neutral"}>
+ {status === HoneyTokenStatus.Active && "Active"}
+ {status === HoneyTokenStatus.Triggered && "Triggered"}
+ {status === HoneyTokenStatus.Revoked && "Revoked"}
</Badge>
</div>
<div
@@ -165,28 +175,30 @@ export const HoneyTokenItem = ({ honeyToken, onEdit, onDelete, onViewCredentials
</IconButton>
)}
</ProjectPermissionCan>
- <ProjectPermissionCan
- I={ProjectPermissionSecretActions.Delete}
- a={ProjectPermissionSub.Secrets}
- renderTooltip
- allowedLabel="Delete"
- >
- {(isAllowed) => (
- <IconButton
- aria-label="Delete honey token"
- variant="danger"
- size="xs"
- className="opacity-0 group-hover:opacity-100"
- onClick={(e) => {
- e.stopPropagation();
- onDelete();
- }}
- isDisabled={!isAllowed}
- >
- <Trash2Icon className="size-4" />
- </IconButton>
- )}
- </ProjectPermissionCan>
+ {status !== HoneyTokenStatus.Revoked && (
+ <ProjectPermissionCan
+ I={ProjectPermissionSecretActions.Delete}
+ a={ProjectPermissionSub.Secrets}
+ renderTooltip
+ allowedLabel="Revoke"
+ >
+ {(isAllowed) => (
+ <IconButton
+ aria-label="Revoke honey token"
+ variant="danger"
+ size="xs"
+ className="opacity-0 group-hover:opacity-100"
+ onClick={(e) => {
+ e.stopPropagation();
+ onRevoke();
+ }}
+ isDisabled={!isAllowed}
+ >
+ <BanIcon className="size-4" />
+ </IconButton>
+ )}
+ </ProjectPermissionCan>
+ )}
</motion.div>
</AnimatePresence>
</div>
diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/HoneyTokenListView/HoneyTokenListView.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/HoneyTokenListView/HoneyTokenListView.tsx
index 82b914c868..80df069b62 100644
--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/HoneyTokenListView/HoneyTokenListView.tsx
+++ b/frontend/src/pages/secret-manager/SecretDashboardPage/components/HoneyTokenListView/HoneyTokenListView.tsx
@@ -1,8 +1,8 @@
import { useState } from "react";
import {
- DeleteHoneyTokenModal,
EditHoneyTokenModal,
+ RevokeHoneyTokenModal,
ViewHoneyTokenCredentialsModal
} from "@app/components/honey-tokens";
import { useWorkspace } from "@app/context";
@@ -18,7 +18,7 @@ export const HoneyTokenListView = ({ honeyTokens }: Props) => {
const { currentWorkspace } = useWorkspace();
const projectId = currentWorkspace?.id || "";
- const [deleteTarget, setDeleteTarget] = useState<TDashboardHoneyToken>();
+ const [revokeTarget, setRevokeTarget] = useState<TDashboardHoneyToken>();
const [editTarget, setEditTarget] = useState<TDashboardHoneyToken>();
const [credentialsTarget, setCredentialsTarget] = useState<TDashboardHoneyToken>();
@@ -29,7 +29,7 @@ export const HoneyTokenListView = ({ honeyTokens }: Props) => {
key={honeyToken.id}
honeyToken={honeyToken}
onEdit={() => setEditTarget(honeyToken)}
- onDelete={() => setDeleteTarget(honeyToken)}
+ onRevoke={() => setRevokeTarget(honeyToken)}
onViewCredentials={() => setCredentialsTarget(honeyToken)}
/>
))}
@@ -40,12 +40,12 @@ export const HoneyTokenListView = ({ honeyTokens }: Props) => {
}}
honeyToken={editTarget}
/>
- <DeleteHoneyTokenModal
- isOpen={Boolean(deleteTarget)}
+ <RevokeHoneyTokenModal
+ isOpen={Boolean(revokeTarget)}
onOpenChange={(isOpen) => {
- if (!isOpen) setDeleteTarget(undefined);
+ if (!isOpen) setRevokeTarget(undefined);
}}
- honeyToken={deleteTarget}
+ honeyToken={revokeTarget}
/>
<ViewHoneyTokenCredentialsModal
isOpen={Boolean(credentialsTarget)}