diff --git a/backend/src/ee/services/access-approval-request/access-approval-request-service.ts b/backend/src/ee/services/access-approval-request/access-approval-request-service.ts index 4cee898f1..8b823ee91 100644 --- a/backend/src/ee/services/access-approval-request/access-approval-request-service.ts +++ b/backend/src/ee/services/access-approval-request/access-approval-request-service.ts @@ -354,11 +354,17 @@ export const accessApprovalRequestServiceFactory = ({ status === ApprovalStatus.APPROVED; const isApprover = policy.approvers.find((approver) => approver.userId === actorId); - // If user is (not an approver OR cant self approve) AND can't bypass policy - if ((!isApprover || (!policy.allowedSelfApprovals && isSelfApproval)) && cannotBypassUnderSoftEnforcement) { - throw new BadRequestError({ - message: "Failed to review access approval request. Users are not authorized to review their own request." - }); + + const isSelfRejection = isSelfApproval && status === ApprovalStatus.REJECTED; + + // users can always reject (cancel) their own requests + if (!isSelfRejection) { + // If user is (not an approver OR cant self approve) AND can't bypass policy + if ((!isApprover || (!policy.allowedSelfApprovals && isSelfApproval)) && cannotBypassUnderSoftEnforcement) { + throw new BadRequestError({ + message: "Failed to review access approval request. Users are not authorized to review their own request." + }); + } } if ( @@ -414,7 +420,7 @@ export const accessApprovalRequestServiceFactory = ({ ); // Only throw if actor is not the approver and not bypassing - if (!isApproverOfTheSequence && !isBreakGlassApprovalAttempt) { + if (!isApproverOfTheSequence && !isBreakGlassApprovalAttempt && !isSelfRejection) { throw new BadRequestError({ message: "You are not a reviewer in this step" }); } } diff --git a/frontend/src/pages/secret-manager/SecretApprovalsPage/components/AccessApprovalRequest/components/ReviewAccessModal.tsx b/frontend/src/pages/secret-manager/SecretApprovalsPage/components/AccessApprovalRequest/components/ReviewAccessModal.tsx index 842c7e030..e9e9c21c4 100644 --- a/frontend/src/pages/secret-manager/SecretApprovalsPage/components/AccessApprovalRequest/components/ReviewAccessModal.tsx +++ b/frontend/src/pages/secret-manager/SecretApprovalsPage/components/AccessApprovalRequest/components/ReviewAccessModal.tsx @@ -255,6 +255,11 @@ export const ReviewAccessRequestModal = ({ return "You are not the reviewer in this step."; }; + // users can always reject (cancel) their own request + const isRejectionDisabled = request.isRequestedByCurrentUser + ? false + : !(request.isApprover && request.isSelfApproveAllowed) && !bypassApproval; + return (