mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 16:27:40 +00:00
fix: resolved trailing slash issue with additional privileges
This commit is contained in:
@@ -0,0 +1,5 @@
|
|||||||
|
export const removeTrailingSlash = (str: string) => {
|
||||||
|
if (str === "/") return str;
|
||||||
|
|
||||||
|
return str.endsWith("/") ? str.slice(0, -1) : str;
|
||||||
|
};
|
||||||
+5
-2
@@ -43,6 +43,7 @@ import {
|
|||||||
useProjectPermission,
|
useProjectPermission,
|
||||||
useWorkspace
|
useWorkspace
|
||||||
} from "@app/context";
|
} from "@app/context";
|
||||||
|
import { removeTrailingSlash } from "@app/helpers/string";
|
||||||
import { usePopUp } from "@app/hooks";
|
import { usePopUp } from "@app/hooks";
|
||||||
import {
|
import {
|
||||||
TProjectUserPrivilege,
|
TProjectUserPrivilege,
|
||||||
@@ -104,7 +105,9 @@ export const SpecificPrivilegeSecretForm = ({
|
|||||||
? {
|
? {
|
||||||
environmentSlug: privilege.permissions?.[0]?.conditions?.environment,
|
environmentSlug: privilege.permissions?.[0]?.conditions?.environment,
|
||||||
// secret path will be inside $glob operator
|
// secret path will be inside $glob operator
|
||||||
secretPath: privilege.permissions?.[0]?.conditions?.secretPath?.$glob || "",
|
secretPath: privilege.permissions?.[0]?.conditions?.secretPath?.$glob
|
||||||
|
? removeTrailingSlash(privilege.permissions?.[0]?.conditions?.secretPath?.$glob)
|
||||||
|
: "",
|
||||||
read: privilege.permissions?.some(({ action }) =>
|
read: privilege.permissions?.some(({ action }) =>
|
||||||
action.includes(ProjectPermissionActions.Read)
|
action.includes(ProjectPermissionActions.Read)
|
||||||
),
|
),
|
||||||
@@ -183,7 +186,7 @@ export const SpecificPrivilegeSecretForm = ({
|
|||||||
];
|
];
|
||||||
const conditions: Record<string, any> = { environment: data.environmentSlug };
|
const conditions: Record<string, any> = { environment: data.environmentSlug };
|
||||||
if (data.secretPath) {
|
if (data.secretPath) {
|
||||||
conditions.secretPath = { $glob: data.secretPath };
|
conditions.secretPath = { $glob: removeTrailingSlash(data.secretPath) };
|
||||||
}
|
}
|
||||||
await updateUserPrivilege.mutateAsync({
|
await updateUserPrivilege.mutateAsync({
|
||||||
privilegeId: privilege.id,
|
privilegeId: privilege.id,
|
||||||
|
|||||||
Reference in New Issue
Block a user