Skip to content

Commit

Permalink
Adding Proxy Privileges
Browse files Browse the repository at this point in the history
Added proxy privileges to GZIPFilter.isGZIPEnabled and AdministrationServiceImpl.getAllowedLocales methods.
  • Loading branch information
wikumChamith committed Jun 20, 2024
1 parent 5ad79d3 commit a8f27dc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import org.openmrs.util.HttpClient;
import org.openmrs.util.LocaleUtility;
import org.openmrs.util.OpenmrsConstants;
import org.openmrs.util.PrivilegeConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cache.annotation.CacheEvict;
Expand Down Expand Up @@ -589,8 +590,15 @@ public List<Locale> getAllowedLocales() {
// update the GlobalLocaleList.allowedLocales by faking a global property change
if (allowedLocales == null) {
// use a default language of "english" if they have cleared this GP for some reason
String currentPropertyValue = Context.getAdministrationService().getGlobalProperty(
OpenmrsConstants.GLOBAL_PROPERTY_LOCALE_ALLOWED_LIST, LocaleUtility.getDefaultLocale().toString());
String currentPropertyValue;
try {
Context.addProxyPrivilege(PrivilegeConstants.GET_GLOBAL_PROPERTIES);
currentPropertyValue = Context.getAdministrationService().getGlobalProperty(
OpenmrsConstants.GLOBAL_PROPERTY_LOCALE_ALLOWED_LIST, LocaleUtility.getDefaultLocale().toString());
}
finally {
Context.removeProxyPrivilege(PrivilegeConstants.GET_GLOBAL_PROPERTIES);
}
GlobalProperty allowedLocalesProperty = new GlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_LOCALE_ALLOWED_LIST,
currentPropertyValue);
globalLocaleList.globalPropertyChanged(allowedLocalesProperty);
Expand Down
5 changes: 5 additions & 0 deletions web/src/main/java/org/openmrs/web/filter/GZIPFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.openmrs.api.APIException;
import org.openmrs.api.context.Context;
import org.openmrs.util.OpenmrsConstants;
import org.openmrs.util.PrivilegeConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.filter.OncePerRequestFilter;
Expand Down Expand Up @@ -124,6 +125,7 @@ private boolean isGZIPEnabled() {
}

try {
Context.addProxyPrivilege(PrivilegeConstants.GET_GLOBAL_PROPERTIES);
String gzipEnabled = Context.getAdministrationService().getGlobalProperty(
OpenmrsConstants.GLOBAL_PROPERTY_GZIP_ENABLED, "");

Expand All @@ -137,6 +139,9 @@ private boolean isGZIPEnabled() {

return false;
}
finally {
Context.removeProxyPrivilege(PrivilegeConstants.GET_GLOBAL_PROPERTIES);
}
}

/**
Expand Down

0 comments on commit a8f27dc

Please sign in to comment.