Skip to content

Commit

Permalink
MID-9380 one more auth check
Browse files Browse the repository at this point in the history
  • Loading branch information
KaterynaHonchar committed Jan 23, 2024
1 parent a77b32d commit 5621b9b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.evolveum.midpoint.gui.impl.component.icon.CompositedIconBuilder;
import com.evolveum.midpoint.gui.impl.component.icon.IconCssStyle;
import com.evolveum.midpoint.model.api.AssignmentObjectRelation;
import com.evolveum.midpoint.model.api.ModelAuthorizationAction;
import com.evolveum.midpoint.prism.PrismContainer;
import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.prism.delta.ObjectDelta;
Expand Down Expand Up @@ -317,6 +318,15 @@ protected void showMainPopup(Popupable popupable, AjaxRequestTarget target) {
@Override
protected boolean isSavePreviewButtonEnabled() {
return !ItemStatus.NOT_CHANGED.equals(getModelObject().getStatus()) || getModelObject().canModify() ||
!getModelObject().isReadOnly(); //this check was added due to MID-9380
isAuthorizedToModify(); //this check was added due to MID-9380
}

protected boolean isAuthorizedToModify() {
try {
return getPageBase().isAuthorized(ModelAuthorizationAction.MODIFY.getUrl(),
AuthorizationPhaseType.EXECUTION, getModelObject().getObject(), null, null);
} catch (Exception e) {
return false;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,18 @@ public UserOperationalButtonsPanel(String id, LoadableModel<PrismObjectWrapper<U

@Override
protected boolean isSavePreviewButtonEnabled() {
return isAuthorizedToModifyUsers() || super.isSavePreviewButtonEnabled();
return isAuthorizedToModify() || super.isSavePreviewButtonEnabled();
}


private boolean isAuthorizedToModifyUsers() {
@Override
protected boolean isAuthorizedToModify() {
try {
return getPageBase().isAuthorized(ModelAuthorizationAction.MODIFY.getUrl(),
boolean selfModify = super.isAuthorizedToModify();
boolean otherUserModify = getPageBase().isAuthorized(ModelAuthorizationAction.MODIFY.getUrl(),
AuthorizationPhaseType.EXECUTION, new UserType().asPrismObject(), null, null);
return selfModify || otherUserModify;
} catch (Exception e) {
return false;
}
}

}

0 comments on commit 5621b9b

Please sign in to comment.