Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TRUNK-6203: Global properties access should be privileged #104

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
TRUNK-6203: Global properties access should be privileged
wikumChamith committed Mar 30, 2024
commit 8ad8ca02433c707ce387fcbfd9b0038e3108eff6
Original file line number Diff line number Diff line change
@@ -33,6 +33,7 @@
import org.openmrs.ui.framework.annotation.SpringBean;
import org.openmrs.ui.framework.page.PageModel;
import org.openmrs.ui.framework.page.PageRequest;
import org.openmrs.util.PrivilegeConstants;
import org.openmrs.web.user.CurrentUsers;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CookieValue;
@@ -150,9 +151,10 @@ public String get(PageModel model, UiUtils ui, PageRequest pageRequest,
}

private boolean isLocationUserPropertyAvailable(AdministrationService administrationService) {
Context.addProxyPrivilege(PrivilegeConstants.GET_GLOBAL_PROPERTIES);
String locationUserPropertyName = administrationService
.getGlobalProperty(ReferenceApplicationConstants.LOCATION_USER_PROPERTY_NAME);

Context.removeProxyPrivilege(PrivilegeConstants.GET_GLOBAL_PROPERTIES);
return StringUtils.isNotBlank(locationUserPropertyName);
}

@@ -376,8 +378,10 @@ private boolean isSameUser(PageRequest pageRequest, String username) {
}

private List<Location> getUserLocations(AdministrationService adminService, LocationService locationService) {
Context.addProxyPrivilege(PrivilegeConstants.GET_GLOBAL_PROPERTIES);
String locationUserPropertyName = adminService
.getGlobalProperty(ReferenceApplicationConstants.LOCATION_USER_PROPERTY_NAME);
Context.removeProxyPrivilege(PrivilegeConstants.GET_GLOBAL_PROPERTIES);
List<Location> locations = new ArrayList();
String locationUuids = Context.getAuthenticatedUser().getUserProperty(locationUserPropertyName);
if (StringUtils.isNotBlank(locationUuids)) {