Skip to content

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

cancel request button

Andrey31377b1ead7b
diff --git a/frontend/src/hooks/api/pam/mutations.tsx b/frontend/src/hooks/api/pam/mutations.tsx
index 8863fd6200..1b7459cb44 100644
--- a/frontend/src/hooks/api/pam/mutations.tsx
+++ b/frontend/src/hooks/api/pam/mutations.tsx
@@ -15,6 +15,7 @@ import {
TAddPamProductIdentityMemberDTO,
TAddPamProductUserMemberDTO,
TBreakGlassPamAccessRequestDTO,
+ TCancelPamAccessRequestDTO,
TCreatePamAccessRequestDTO,
TCreatePamAccountDTO,
TCreatePamAccountTemplateDTO,
@@ -905,6 +906,22 @@ export const useBreakGlassPamAccessRequest = () => {
});
};
+export const useCancelPamAccessRequest = () => {
+ const queryClient = useQueryClient();
+ return useMutation({
+ mutationFn: async ({ requestId }: TCancelPamAccessRequestDTO) => {
+ const { data } = await apiRequest.post(
+ `/api/v1/approval-policies/pam-access/requests/${requestId}/cancel`
+ );
+ return data;
+ },
+ onSuccess: () => {
+ queryClient.invalidateQueries({ queryKey: pamKeys.accessRequest() });
+ queryClient.invalidateQueries({ queryKey: pamKeys.account() });
+ }
+ });
+};
+
export const useSetPamApprovalConfig = () => {
const queryClient = useQueryClient();
return useMutation({
diff --git a/frontend/src/hooks/api/pam/types/index.ts b/frontend/src/hooks/api/pam/types/index.ts
index 03017323b8..cac1ee62fc 100644
--- a/frontend/src/hooks/api/pam/types/index.ts
+++ b/frontend/src/hooks/api/pam/types/index.ts
@@ -810,6 +810,10 @@ export type TBreakGlassPamAccessRequestDTO = {
bypassReason: string;
};
+export type TCancelPamAccessRequestDTO = {
+ requestId: string;
+};
+
export type TSetPamApprovalConfigDTO = {
folderId: string;
steps: {
diff --git a/frontend/src/pages/pam/components/RequestAccessSheet.tsx b/frontend/src/pages/pam/components/RequestAccessSheet.tsx
index b1f64a0196..e07148e085 100644
--- a/frontend/src/pages/pam/components/RequestAccessSheet.tsx
+++ b/frontend/src/pages/pam/components/RequestAccessSheet.tsx
@@ -49,6 +49,7 @@ import {
TAccessiblePamAccount,
TPamApprovalWorkflowStep,
useBreakGlassPamAccessRequest,
+ useCancelPamAccessRequest,
useCreatePamAccessRequest,
useGetPamAccountApprovers
} from "@app/hooks/api/pam";
@@ -186,6 +187,7 @@ export const RequestAccessSheet = ({
const createRequest = useCreatePamAccessRequest();
const formId = useId();
const breakGlass = useBreakGlassPamAccessRequest();
+ const cancelRequest = useCancelPamAccessRequest();
const [bypassReason, setBypassReason] = useState("");
const [autoApprovalValues, setAutoApprovalValues] = useState<Record<string, string>>({});
const isCredentialRequest = accessType === PamAccessType.Credential;
@@ -230,6 +232,22 @@ export const RequestAccessSheet = ({
onOpenChange(open);
};
+ const onCancelRequest = () => {
+ if (!pendingRequestId) return;
+ cancelRequest.mutate(
+ { requestId: pendingRequestId },
+ {
+ onSuccess: () => {
+ createNotification({
+ text: isCredentialRequest ? "Credential request canceled" : "Access request canceled",
+ type: "success"
+ });
+ handleOpenChange(false);
+ }
+ }
+ );
+ };
+
const onBreakGlass = () => {
if (!pendingRequestId) return;
breakGlass.mutate(
@@ -317,7 +335,18 @@ export const RequestAccessSheet = ({
metadata={metadata}
isDirty={(isDirty || hasAutoApprovalValues) && !isPending}
contentFooter={
- !isPending && (
+ isPending ? (
+ pendingRequestId && (
+ <Button
+ type="button"
+ variant="danger"
+ isPending={cancelRequest.isPending}
+ onClick={onCancelRequest}
+ >
+ Cancel Request
+ </Button>
+ )
+ ) : (
<>
<Button type="button" variant="ghost" onClick={() => handleOpenChange(false)}>
Cancel