Skip to content

Commit

Permalink
Changes related to download group
Browse files Browse the repository at this point in the history
  • Loading branch information
kalletlak committed Jul 3, 2023
1 parent 49adca0 commit 6709c73
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,13 @@
import java.util.List;
import java.util.Properties;

import org.apache.commons.lang.StringUtils;
import org.cbioportal.security.spring.authentication.PortalUserDetails;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Component;
import org.springframework.util.ResourceUtils;
Expand Down Expand Up @@ -362,6 +364,10 @@ public static String parseUrl(String url)
@Value("${frontend.url.runtime:}")
public void setFrontendUrlRuntime(String property) { frontendUrlRuntime = property; }

private static String downloadGroup;
@Value("${download_group:}") // default is empty string
public void setDownloadGroup(String property) { downloadGroup = property; }

private static Logger LOG = LoggerFactory.getLogger(GlobalProperties.class);
private static ConfigPropertyResolver portalProperties = new ConfigPropertyResolver();
private static Properties mavenProperties = initializeProperties(MAVEN_PROPERTIES_FILE_NAME);
Expand Down Expand Up @@ -551,6 +557,18 @@ public static String getAuthenticatedUserEmail() {
}
}

public static String hideDownloadControls() {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();

if(authentication != null &&
StringUtils.isNotEmpty(downloadGroup) &&
authentication.getAuthorities().contains(new SimpleGrantedAuthority(downloadGroup))) {
return "false";
}else {
return getProperty("skin.hide_download_controls");
}
}

public static String getAppName()
{
String appName = portalProperties.getProperty(APP_NAME);
Expand Down
3 changes: 2 additions & 1 deletion portal/src/main/webapp/config_service.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@
"skin.patient_view.copy_number_table.columns.show_on_init",
"skin.patient_view.structural_variant_table.columns.show_on_init",
"comparison.categorical_na_values",
"skin.hide_download_controls",
"study_download_url",
"skin.home_page.show_reference_genome"
};
Expand Down Expand Up @@ -203,6 +202,8 @@
obj.put("oncoKbTokenDefined", !StringUtils.isEmpty(GlobalProperties.getOncoKbToken()));
obj.put("sessionServiceEnabled", !StringUtils.isEmpty(GlobalProperties.getSessionServiceUrl()));
obj.put("skin_hide_download_controls", GlobalProperties.hideDownloadControls());
out.println(obj.toJSONString());
Expand Down
4 changes: 3 additions & 1 deletion src/main/resources/portal.properties.EXAMPLE
Original file line number Diff line number Diff line change
Expand Up @@ -433,4 +433,6 @@ persistence.cache_type=no-cache

# Set StudyDownloadLinkUrl
# Allows download links within DataSets Tab (See Portal.Properties documentation for more info)
# study_download_url=
# study_download_url=

# download_group=

0 comments on commit 6709c73

Please sign in to comment.