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

FIX-11364 Proxy Controller and Monkifier #11365

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
17 changes: 17 additions & 0 deletions docs/deployment/customization/application.properties-Reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -826,3 +826,20 @@ Custom Buttons can be defined which will conditionally appear in all group compa
```
download_custom_buttons_json=classpath:custom_buttons/download_custom_button_avm.json
```

# Proxy Service
cBioPortal can act as a proxy service so that users can run installations of different services behind firewalls that can't be reach by all users. To do this users set a proxy.routes.[name] property in the application.properties. This will create a proxy endpoint at /proxy/[name].

As an example if you wanted to host genomenexus locally then you could set it in the following manner.

```
# Setup proxy routes
proxy.routes.genomenexus=http://gn-spring-boot:8888
proxy.routes.genomenexus38=http://gn-spring-boot-grch38:8888

# GenomeNexus configuration
genomenexus.url=/proxy/genomenexus
genomenexus.url.grch38=/proxy/genomenexus38
```

NOTE: The proxy service is available to all logged in users and it is not recommended to be used on public non-secured instances of cBioPortal.
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
<!-- Version properties for dependencies that should have same version. -->
<!-- The rest can be set in the dependencyManagement section -->
<spring.social.version>1.1.6.RELEASE</spring.social.version>
<spring_cloud_gateway_mvc.version>4.1.5</spring_cloud_gateway_mvc.version>

<jackson.version>2.12.5</jackson.version>
<mysql-connector.version>8.0.28</mysql-connector.version>
Expand Down Expand Up @@ -385,6 +386,11 @@
<artifactId>spring-boot-testcontainers</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-gateway-mvc</artifactId>
<version>${spring_cloud_gateway_mvc.version}</version>
</dependency>
</dependencies>

<dependencyManagement>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@

@Controller
@RequestMapping("/api/proxy")
public class LegacyProxyController {
public class APIProxyController {

private String bitlyURL;
private String sessionServiceURL;
Expand Down
16 changes: 7 additions & 9 deletions src/main/java/org/cbioportal/proxy/Monkifier.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import jakarta.servlet.http.HttpServletRequest;
import org.apache.commons.codec.binary.Base64;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import org.springframework.web.util.UriComponentsBuilder;

Expand All @@ -11,32 +10,31 @@
import java.util.Map;
import java.util.stream.Collectors;

@Component
public class Monkifier {
public String decodeBase64(String value) {
public static String decodeBase64(String value) {
return new String(Base64.decodeBase64(value.getBytes()));
}

public String encodeBase64(String value) {
public static String encodeBase64(String value) {
return value == null ? "": new String(Base64.encodeBase64(value.getBytes()));
}

public String decodeQueryString(HttpServletRequest request) {
public static String decodeQueryString(HttpServletRequest request) {
if (request.getQueryString() == null) {
return null;
}

return this.decodeQueryString(request.getParameterMap());
return decodeQueryString(request.getParameterMap());
}

public String decodeQueryString(Map<String, String[]> encodedQueryParams) {
public static String decodeQueryString(Map<String, String[]> encodedQueryParams) {
Map<String, List<String>> decodedQueryParams = encodedQueryParams
.entrySet()
.stream()
.collect(
Collectors.toMap(
e -> this.decodeBase64(e.getKey()),
e -> Arrays.stream(e.getValue()).map(this::decodeBase64).collect(Collectors.toList())
e -> Monkifier.decodeBase64(e.getKey()),
e -> Arrays.stream(e.getValue()).map(Monkifier::decodeBase64).collect(Collectors.toList())
)
);

Expand Down
193 changes: 0 additions & 193 deletions src/main/java/org/cbioportal/proxy/ProxyController.java

This file was deleted.

Loading
Loading