Skip to content

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

Refactor secret permission validation in InfisicalSecretInput and improve tooltip styling in CreateSecretForm components

Victor Santos2083e9102f11
diff --git a/frontend/src/components/v2/InfisicalSecretInput/InfisicalSecretInput.tsx b/frontend/src/components/v2/InfisicalSecretInput/InfisicalSecretInput.tsx
index 82a6526244..d1f2e1a624 100644
--- a/frontend/src/components/v2/InfisicalSecretInput/InfisicalSecretInput.tsx
+++ b/frontend/src/components/v2/InfisicalSecretInput/InfisicalSecretInput.tsx
@@ -389,30 +389,26 @@ export const InfisicalSecretInput = forwardRef<HTMLTextAreaElement, Props>(
const secretPath = segment === environmentSlug ? "/" : folderPath;
- const canReadSecretValue = hasSecretReadValueOrDescribePermission(
- permission,
- ProjectPermissionSecretActions.ReadValue,
- {
- environment: environmentSlug,
- secretPath,
- secretName: secretName ?? "*",
- secretTags: ["*"]
- }
- );
-
- let resourceName = "secret";
- if (segment === environmentSlug) {
- resourceName = "environment";
- } else if (segment !== secretName && folderPath.includes(segment)) {
- resourceName = "folder";
- }
+ // Only validate secret permission, users can always view environments and folders
+ if (segment === secretName) {
+ const canReadSecretValue = hasSecretReadValueOrDescribePermission(
+ permission,
+ ProjectPermissionSecretActions.ReadValue,
+ {
+ environment: environmentSlug,
+ secretPath,
+ secretName: secretName ?? "*",
+ secretTags: ["*"]
+ }
+ );
- if (!canReadSecretValue) {
- createNotification({
- text: `You do not have permission to access this ${resourceName}`,
- type: "error"
- });
- return;
+ if (!canReadSecretValue) {
+ createNotification({
+ text: "You do not have permission to access this secret",
+ type: "error"
+ });
+ return;
+ }
}
navigate({
diff --git a/frontend/src/pages/secret-manager/OverviewPage/components/CreateSecretForm/CreateSecretForm.tsx b/frontend/src/pages/secret-manager/OverviewPage/components/CreateSecretForm/CreateSecretForm.tsx
index 2ed31e50cf..a821a029d5 100644
--- a/frontend/src/pages/secret-manager/OverviewPage/components/CreateSecretForm/CreateSecretForm.tsx
+++ b/frontend/src/pages/secret-manager/OverviewPage/components/CreateSecretForm/CreateSecretForm.tsx
@@ -252,15 +252,15 @@ export const CreateSecretForm = ({ secretPath = "/", onClose }: Props) => {
tooltipText={
<div>
You can add references to other secrets using the format{" "}
- <code>
+ <code className="rounded-sm bg-mineshaft-600 px-1 py-0.5">
&#36;{"{"}secret_name{"}"}
</code>
<br />
<br />
You can go to the referenced secret by holding the{" "}
- <code className="rounded-sm bg-mineshaft-600 p-0.5">Cmd</code> (Mac) or{" "}
- <code className="rounded-sm bg-mineshaft-600 p-0.5">Ctrl</code> (Windows/Linux) key
- and clicking on the secret name.
+ <code className="rounded-sm bg-mineshaft-600 px-1 py-0.5">Cmd</code> (Mac) or{" "}
+ <code className="rounded-sm bg-mineshaft-600 px-1 py-0.5">Ctrl</code>{" "}
+ (Windows/Linux) key and clicking on the secret name.
</div>
}
tooltipClassName="max-w-md"
diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/SecretDashboardPage.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/SecretDashboardPage.tsx
index a16e6cd886..53fc476adf 100644
--- a/frontend/src/pages/secret-manager/SecretDashboardPage/SecretDashboardPage.tsx
+++ b/frontend/src/pages/secret-manager/SecretDashboardPage/SecretDashboardPage.tsx
@@ -219,17 +219,19 @@ const Page = () => {
ProjectPermissionSub.Commits
);
+ const defaultIncludeFilters = {
+ [RowType.Folder]: routerQueryParams.filterBy?.includes(RowType.Folder) || false,
+ [RowType.Import]: routerQueryParams.filterBy?.includes(RowType.Import) || false,
+ [RowType.DynamicSecret]: routerQueryParams.filterBy?.includes(RowType.DynamicSecret) || false,
+ [RowType.Secret]: routerQueryParams.filterBy?.includes(RowType.Secret) || false,
+ [RowType.SecretRotation]: routerQueryParams.filterBy?.includes(RowType.SecretRotation) || false
+ };
+
const defaultFilterState = {
tags: {},
searchFilter: (routerQueryParams.search as string) || "",
// these should always be on by default for the UI, they will be disabled for the query below based off permissions
- include: {
- [RowType.Folder]: false,
- [RowType.Import]: false,
- [RowType.DynamicSecret]: false,
- [RowType.Secret]: false,
- [RowType.SecretRotation]: false
- }
+ include: defaultIncludeFilters
};
const [filter, setFilter] = useState<Filter>(defaultFilterState);
@@ -529,6 +531,19 @@ const Page = () => {
[navigate]
);
+ const handleClearFilters = useCallback(() => {
+ setFilter(defaultFilterState);
+ setDebouncedSearchFilter("");
+ navigate({
+ search: (prev) => ({
+ ...prev,
+ search: "",
+ tags: "",
+ filterBy: ""
+ })
+ });
+ }, [navigate]);
+
const handleSearchChange = useCallback(
(searchFilter: string) => {
setFilter((state) => ({ ...state, searchFilter }));
@@ -882,19 +897,7 @@ const Page = () => {
isPITEnabled={isPITEnabled}
hasPathPolicies={hasPathPolicies}
onRequestAccess={(params) => handlePopUpOpen("requestAccess", params)}
- onClearFilters={() =>
- setFilter((prev) => ({
- ...prev,
- tags: {},
- include: {
- secret: false,
- import: false,
- dynamic: false,
- rotation: false,
- folder: false
- }
- }))
- }
+ onClearFilters={handleClearFilters}
/>
<div
ref={tableRef}
diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/CreateSecretForm/CreateSecretForm.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/CreateSecretForm/CreateSecretForm.tsx
index 1a4884ddb3..860c59c1e4 100644
--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/CreateSecretForm/CreateSecretForm.tsx
+++ b/frontend/src/pages/secret-manager/SecretDashboardPage/components/CreateSecretForm/CreateSecretForm.tsx
@@ -200,15 +200,15 @@ export const CreateSecretForm = ({
tooltipText={
<div>
You can add references to other secrets using the format{" "}
- <code>
+ <code className="rounded-sm bg-mineshaft-600 px-1 py-0.5">
&#36;{"{"}secret_name{"}"}
</code>
<br />
<br />
You can go to the referenced secret by holding the{" "}
- <code className="rounded-sm bg-mineshaft-600 p-0.5">Cmd</code> (Mac) or{" "}
- <code className="rounded-sm bg-mineshaft-600 p-0.5">Ctrl</code> (Windows/Linux) key
- and clicking on the secret name.
+ <code className="rounded-sm bg-mineshaft-600 px-1 py-0.5">Cmd</code> (Mac) or{" "}
+ <code className="rounded-sm bg-mineshaft-600 px-1 py-0.5">Ctrl</code>{" "}
+ (Windows/Linux) key and clicking on the secret name.
</div>
}
tooltipClassName="max-w-md"