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
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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)) {
Expand Down
Loading