Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
better ux
Matheus Nogueira0098b04070f2
diff --git a/backend/src/ee/routes/v1/honey-token-router.ts b/backend/src/ee/routes/v1/honey-token-router.tsindex 12e43bd79a..aa5b35c385 100644--- a/backend/src/ee/routes/v1/honey-token-router.ts+++ b/backend/src/ee/routes/v1/honey-token-router.ts@@ -139,6 +139,38 @@ export const registerHoneyTokenRouter = async (server: FastifyZodProvider) => {}});+ server.route({+ url: "/:honeyTokenId/credentials",+ method: "GET",+ config: {+ rateLimit: readLimit+ },+ onRequest: verifyAuth([AuthMode.JWT]),+ schema: {+ params: z.object({+ honeyTokenId: z.string().uuid()+ }),+ querystring: z.object({+ projectId: z.string().trim()+ }),+ response: {+ 200: z.object({+ credentials: z.record(z.string(), z.string())+ })+ }+ },+ handler: async (req) => {+ const { credentials } = await server.services.honeyTokenCrud.getCredentials(+ {+ honeyTokenId: req.params.honeyTokenId,+ projectId: req.query.projectId+ },+ req.permission+ );+ return { credentials };+ }+ });+server.route({url: "/configs",method: "PUT",diff --git a/backend/src/ee/services/honey-token/honey-token-service.ts b/backend/src/ee/services/honey-token/honey-token-service.tsindex 9c9b887853..8d01a8d8ca 100644--- a/backend/src/ee/services/honey-token/honey-token-service.ts+++ b/backend/src/ee/services/honey-token/honey-token-service.ts@@ -612,10 +612,51 @@ export const honeyTokenServiceFactory = ({return honeyTokens;};+ const getCredentials = async (+ { honeyTokenId, projectId }: { honeyTokenId: string; projectId: string },+ actor: OrgServiceActor+ ) => {+ const { permission } = await permissionService.getProjectPermission({+ actor: actor.type,+ actorId: actor.id,+ actorAuthMethod: actor.authMethod,+ actorOrgId: actor.orgId,+ actionProjectType: ActionProjectType.SecretManager,+ projectId+ });++ ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionSecretActions.DescribeAndReadValue, ProjectPermissionSub.Secrets);++ const honeyToken = await honeyTokenDAL.findById(honeyTokenId);++ if (!honeyToken || honeyToken.projectId !== projectId) {+ throw new NotFoundError({ message: `Honey token with ID "${honeyTokenId}" not found` });+ }++ const { decryptor } = await kmsService.createCipherPairWithDataKey({+ type: KmsDataKey.Organization,+ orgId: actor.orgId+ });++ const decryptedCredentials = JSON.parse(+ decryptor({ cipherTextBlob: honeyToken.encryptedCredentials }).toString()+ ) as Record<string, string>;++ const mapping = honeyToken.secretsMapping as Record<string, string>;++ const credentials: Record<string, string> = {};+ for (const [credentialKey, secretName] of Object.entries(mapping)) {+ credentials[secretName] = decryptedCredentials[credentialKey] ?? "";+ }++ return { credentials };+ };+return {create,updateHoneyToken,deleteHoneyToken,+ getCredentials,getDashboardHoneyTokenCount,getDashboardHoneyTokens};diff --git a/frontend/src/components/honey-tokens/ViewHoneyTokenCredentialsModal.tsx b/frontend/src/components/honey-tokens/ViewHoneyTokenCredentialsModal.tsxnew file mode 100644index 0000000000..72f05af374--- /dev/null+++ b/frontend/src/components/honey-tokens/ViewHoneyTokenCredentialsModal.tsx@@ -0,0 +1,70 @@+import { CredentialDisplay } from "@app/components/secret-rotations-v2/ViewSecretRotationV2GeneratedCredentials/shared/CredentialDisplay";+import { ViewRotationGeneratedCredentialsDisplay } from "@app/components/secret-rotations-v2/ViewSecretRotationV2GeneratedCredentials/shared/ViewRotationGeneratedCredentialsDisplay";+import { Modal, ModalContent, Spinner } from "@app/components/v2";+import { HONEY_TOKEN_CREDENTIAL_FIELDS } from "@app/helpers/honeyTokens";+import { useGetHoneyTokenCredentials } from "@app/hooks/api/honeyTokens";+import { HoneyTokenType, TDashboardHoneyToken } from "@app/hooks/api/honeyTokens/types";++type Props = {+ honeyToken?: TDashboardHoneyToken;+ projectId: string;+ isOpen: boolean;+ onOpenChange: (isOpen: boolean) => void;+};++export const ViewHoneyTokenCredentialsModal = ({+ honeyToken,+ projectId,+ isOpen,+ onOpenChange+}: Props) => {+ const { data: credentials, isPending } = useGetHoneyTokenCredentials({+ honeyTokenId: honeyToken?.id ?? "",+ projectId,+ enabled: isOpen && Boolean(honeyToken)+ });++ const credentialFields = honeyToken+ ? HONEY_TOKEN_CREDENTIAL_FIELDS[honeyToken.type as HoneyTokenType]+ : [];++ return (+ <Modal isOpen={isOpen} onOpenChange={onOpenChange}>+ <ModalContent+ onOpenAutoFocus={(e) => e.preventDefault()}+ title="Generated Credentials"+ subTitle={honeyToken ? `View the credentials for "${honeyToken.name}".` : ""}+ >+ {isPending ? (+ <div className="flex flex-col items-center justify-center py-4">+ <Spinner size="lg" className="text-mineshaft-500" />+ <p className="mt-4 text-sm text-mineshaft-400">Loading credentials...</p>+ </div>+ ) : credentials ? (+ <ViewRotationGeneratedCredentialsDisplay+ activeCredentials={+ <>+ {credentialFields.map(({ key, label }) => {+ const secretName = honeyToken?.secretsMapping?.[key];+ const value = secretName ? credentials[secretName] : undefined;++ return (+ <CredentialDisplay+ key={key}+ label={label}+ isSensitive+ >+ {value}+ </CredentialDisplay>+ );+ })}+ </>+ }+ />+ ) : (+ <p className="text-sm text-red">No credentials found for this honey token.</p>+ )}+ </ModalContent>+ </Modal>+ );+};diff --git a/frontend/src/components/honey-tokens/index.ts b/frontend/src/components/honey-tokens/index.tsindex e80b9f8a8f..28679b5883 100644--- a/frontend/src/components/honey-tokens/index.ts+++ b/frontend/src/components/honey-tokens/index.ts@@ -1,3 +1,4 @@export * from "./CreateHoneyTokenModal";export * from "./DeleteHoneyTokenModal";export * from "./EditHoneyTokenModal";+export * from "./ViewHoneyTokenCredentialsModal";diff --git a/frontend/src/hooks/api/honeyTokens/queries.tsx b/frontend/src/hooks/api/honeyTokens/queries.tsxindex 3e2f309246..fe13039ccb 100644--- a/frontend/src/hooks/api/honeyTokens/queries.tsx+++ b/frontend/src/hooks/api/honeyTokens/queries.tsx@@ -1,4 +1,30 @@+import { useQuery } from "@tanstack/react-query";++import { apiRequest } from "@app/config/request";+export const honeyTokenKeys = {all: ["honeyTokens"] as const,- list: (projectId: string) => [...honeyTokenKeys.all, "list", projectId] as const+ list: (projectId: string) => [...honeyTokenKeys.all, "list", projectId] as const,+ credentials: (honeyTokenId: string) => [...honeyTokenKeys.all, "credentials", honeyTokenId] as const};++export const useGetHoneyTokenCredentials = ({+ honeyTokenId,+ projectId,+ enabled = true+}: {+ honeyTokenId: string;+ projectId: string;+ enabled?: boolean;+}) =>+ useQuery({+ queryKey: honeyTokenKeys.credentials(honeyTokenId),+ queryFn: async () => {+ const { data } = await apiRequest.get<{ credentials: Record<string, string> }>(+ `/api/v1/honey-tokens/${honeyTokenId}/credentials`,+ { params: { projectId } }+ );+ return data.credentials;+ },+ enabled+ });diff --git a/frontend/src/pages/secret-manager/OverviewPage/OverviewPage.tsx b/frontend/src/pages/secret-manager/OverviewPage/OverviewPage.tsxindex e345f7f0a6..adf9a7d06b 100644--- a/frontend/src/pages/secret-manager/OverviewPage/OverviewPage.tsx+++ b/frontend/src/pages/secret-manager/OverviewPage/OverviewPage.tsx@@ -29,7 +29,11 @@ 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, EditHoneyTokenModal } from "@app/components/honey-tokens";+import {+ DeleteHoneyTokenModal,+ EditHoneyTokenModal,+ ViewHoneyTokenCredentialsModal+} from "@app/components/honey-tokens";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";@@ -779,7 +783,8 @@ const OverviewPageContent = () => {"importFromDoppler","confirmDisableBatchMode","editHoneyToken",- "deleteHoneyToken"+ "deleteHoneyToken",+ "viewHoneyTokenCredentials"] as const);// Auto-open dynamic secret leases modal when linked via notification/email@@ -3089,6 +3094,9 @@ const OverviewPageContent = () => {onDelete={(honeyToken) =>handlePopUpOpen("deleteHoneyToken", honeyToken)}+ onViewCredentials={(honeyToken) =>+ handlePopUpOpen("viewHoneyTokenCredentials", honeyToken)+ }/>))}{mergedSecKeys.map((key, index) => (@@ -3438,6 +3446,12 @@ const OverviewPageContent = () => {honeyToken={popUp.deleteHoneyToken.data as TDashboardHoneyToken}onOpenChange={(isOpen) => handlePopUpToggle("deleteHoneyToken", isOpen)}/>+ <ViewHoneyTokenCredentialsModal+ isOpen={popUp.viewHoneyTokenCredentials.isOpen}+ honeyToken={popUp.viewHoneyTokenCredentials.data as TDashboardHoneyToken}+ projectId={projectId}+ onOpenChange={(isOpen) => handlePopUpToggle("viewHoneyTokenCredentials", isOpen)}+ /><ImportSecretsModalisOpen={popUp.importSecrets.isOpen}onOpenChange={(isOpen) => {diff --git a/frontend/src/pages/secret-manager/OverviewPage/components/HoneyTokenTableRow/HoneyTokenTableRow.tsx b/frontend/src/pages/secret-manager/OverviewPage/components/HoneyTokenTableRow/HoneyTokenTableRow.tsxindex 3912afc75e..e73622383d 100644--- a/frontend/src/pages/secret-manager/OverviewPage/components/HoneyTokenTableRow/HoneyTokenTableRow.tsx+++ b/frontend/src/pages/secret-manager/OverviewPage/components/HoneyTokenTableRow/HoneyTokenTableRow.tsx@@ -1,4 +1,4 @@-import { ChevronDownIcon, EditIcon, InfoIcon, SirenIcon, TrashIcon } from "lucide-react";+import { AsteriskIcon, ChevronDownIcon, EditIcon, InfoIcon, SirenIcon, TrashIcon } from "lucide-react";import { twMerge } from "tailwind-merge";import { ProjectPermissionCan } from "@app/components/permissions";@@ -37,6 +37,7 @@ type Props = {tableWidth: number;onEdit: (honeyToken: TDashboardHoneyToken) => void;onDelete: (honeyToken: TDashboardHoneyToken) => void;+ onViewCredentials: (honeyToken: TDashboardHoneyToken) => void;};export const HoneyTokenTableRow = ({@@ -46,7 +47,8 @@ export const HoneyTokenTableRow = ({getHoneyTokenByName,tableWidth,onEdit,- onDelete+ onDelete,+ onViewCredentials}: Props) => {const [isExpanded, setIsExpanded] = useToggle(false);@@ -72,6 +74,27 @@ export const HoneyTokenTableRow = ({"group-hover:pointer-events-auto group-hover:gap-1 group-hover:opacity-100")}>+ <ProjectPermissionCan+ I={ProjectPermissionSecretActions.DescribeAndReadValue}+ 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"+ isDisabled={!isAllowed}+ onClick={() => onViewCredentials(honeyToken)}+ >+ <AsteriskIcon />+ </IconButton>+ </TooltipTrigger>+ <TooltipContent>View credentials</TooltipContent>+ </Tooltip>+ )}+ </ProjectPermissionCan><ProjectPermissionCanI={ProjectPermissionSecretActions.Edit}a={ProjectPermissionSub.Secrets}diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/HoneyTokenListView/HoneyTokenItem.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/HoneyTokenListView/HoneyTokenItem.tsxindex 14a71e4b6e..b201871513 100644--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/HoneyTokenListView/HoneyTokenItem.tsx+++ b/frontend/src/pages/secret-manager/SecretDashboardPage/components/HoneyTokenListView/HoneyTokenItem.tsx@@ -1,5 +1,5 @@import { useState } from "react";-import { faEdit, faInfoCircle, faTrash } from "@fortawesome/free-solid-svg-icons";+import { faAsterisk, faEdit, faInfoCircle, faTrash } from "@fortawesome/free-solid-svg-icons";import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";import { AnimatePresence, motion } from "framer-motion";import { SirenIcon } from "lucide-react";@@ -20,9 +20,10 @@ type Props = {honeyToken: TDashboardHoneyToken;onEdit: () => void;onDelete: () => void;+ onViewCredentials: () => void;};-export const HoneyTokenItem = ({ honeyToken, onEdit, onDelete }: Props) => {+export const HoneyTokenItem = ({ honeyToken, onEdit, onDelete, onViewCredentials }: Props) => {const { name, type, status, secretsMapping } = honeyToken;const [isExpanded, setIsExpanded] = useState(true);@@ -84,11 +85,32 @@ export const HoneyTokenItem = ({ honeyToken, onEdit, onDelete }: Props) => {<AnimatePresence mode="wait"><motion.divkey="options"- className="flex w-16 items-center justify-between border-l border-mineshaft-600 px-2 py-3"+ className="flex w-24 items-center justify-between border-l border-mineshaft-600 px-2 py-3"initial={{ x: 0, opacity: 0 }}animate={{ x: 0, opacity: 1 }}exit={{ x: 10, opacity: 0 }}>+ <ProjectPermissionCan+ I={ProjectPermissionSecretActions.DescribeAndReadValue}+ a={ProjectPermissionSub.Secrets}+ renderTooltip+ allowedLabel="View credentials"+ >+ {(isAllowed) => (+ <IconButton+ ariaLabel="View credentials"+ variant="plain"+ isDisabled={!isAllowed}+ className="opacity-0 group-hover:opacity-100"+ onClick={(e) => {+ e.stopPropagation();+ onViewCredentials();+ }}+ >+ <FontAwesomeIcon icon={faAsterisk} />+ </IconButton>+ )}+ </ProjectPermissionCan><ProjectPermissionCanI={ProjectPermissionSecretActions.Edit}a={ProjectPermissionSub.Secrets}diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/HoneyTokenListView/HoneyTokenListView.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/HoneyTokenListView/HoneyTokenListView.tsxindex 0514944ca3..82b914c868 100644--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/HoneyTokenListView/HoneyTokenListView.tsx+++ b/frontend/src/pages/secret-manager/SecretDashboardPage/components/HoneyTokenListView/HoneyTokenListView.tsx@@ -1,6 +1,11 @@import { useState } from "react";-import { DeleteHoneyTokenModal, EditHoneyTokenModal } from "@app/components/honey-tokens";+import {+ DeleteHoneyTokenModal,+ EditHoneyTokenModal,+ ViewHoneyTokenCredentialsModal+} from "@app/components/honey-tokens";+import { useWorkspace } from "@app/context";import { TDashboardHoneyToken } from "@app/hooks/api/honeyTokens/types";import { HoneyTokenItem } from "./HoneyTokenItem";@@ -10,8 +15,12 @@ type Props = {};export const HoneyTokenListView = ({ honeyTokens }: Props) => {+ const { currentWorkspace } = useWorkspace();+ const projectId = currentWorkspace?.id || "";+const [deleteTarget, setDeleteTarget] = useState<TDashboardHoneyToken>();const [editTarget, setEditTarget] = useState<TDashboardHoneyToken>();+ const [credentialsTarget, setCredentialsTarget] = useState<TDashboardHoneyToken>();return (<>@@ -21,6 +30,7 @@ export const HoneyTokenListView = ({ honeyTokens }: Props) => {honeyToken={honeyToken}onEdit={() => setEditTarget(honeyToken)}onDelete={() => setDeleteTarget(honeyToken)}+ onViewCredentials={() => setCredentialsTarget(honeyToken)}/>))}<EditHoneyTokenModal@@ -37,6 +47,14 @@ export const HoneyTokenListView = ({ honeyTokens }: Props) => {}}honeyToken={deleteTarget}/>+ <ViewHoneyTokenCredentialsModal+ isOpen={Boolean(credentialsTarget)}+ onOpenChange={(isOpen) => {+ if (!isOpen) setCredentialsTarget(undefined);+ }}+ honeyToken={credentialsTarget}+ projectId={projectId}+ /></>);};