Skip to content

Commit

Permalink
Merge branch 'release/2.5.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
LEDfan committed Mar 2, 2021
2 parents 18041ed + 4512946 commit 30675f0
Show file tree
Hide file tree
Showing 21 changed files with 128 additions and 54 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/workflows.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Tests

on: [push]

jobs:
tests:
runs-on: ubuntu-latest
strategy:
matrix:
java: [ 8, 11 ]

steps:
- uses: actions/checkout@v2
- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: ${{ matrix.java }}
- name: Cache Maven packages
uses: actions/cache@v2
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Build with Maven
run: mvn -U clean install -DskipTests
- name: Run Tests
run: mvn test

dependency:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Run Dependency Check
run: mvn -Powasp-dependency-check verify -DskipTests
- name: Archive code coverage results
uses: actions/upload-artifact@v2
with:
name: dependency-check-report
path: target/dependency-check-report.html

5 changes: 0 additions & 5 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE_HEADER
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ShinyProxy

Copyright (C) 2016-2020 Open Analytics
Copyright (C) 2016-2021 Open Analytics

===========================================================================

Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<pre>
_____ _ _ _____
/ ____| | (_) | __ \
| (___ | |__ _ _ __ _ _| |__) | __ _____ ___ _
_____ _ _ _____
/ ____| | (_) | __ \
| (___ | |__ _ _ __ _ _| |__) | __ _____ ___ _
\___ \| '_ \| | '_ \| | | | ___/ '__/ _ \ \/ / | | |
____) | | | | | | | | |_| | | | | | (_) > <| |_| |
|_____/|_| |_|_|_| |_|\__, |_| |_| \___/_/\_\\__, |
__/ | __/ |
|___/ |___/
|___/ |___/

</pre>

Expand All @@ -18,7 +18,7 @@ Open Source Enterprise Deployment for Shiny Apps

Learn more at https://shinyproxy.io

#### (c) Copyright Open Analytics NV, 2016-2020 - Apache License 2.0
#### (c) Copyright Open Analytics NV, 2016-2021 - Apache License 2.0

## Building from source

Expand All @@ -33,7 +33,7 @@ The build will result in a single `.jar` file that is made available in the `tar
## Running the application

```
java -jar shinyproxy-2.3.0.jar
java -jar shinyproxy-2.3.0.jar
```

Navigate to http://localhost:8080 to access the application. If the default configuration is used, authentication will be done against the LDAP server at *ldap.forumsys.com*; to log in one can use the user name "tesla" and password "password".
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>eu.openanalytics</groupId>
<artifactId>shinyproxy</artifactId>
<version>2.4.3</version>
<version>2.5.0</version>
<packaging>jar</packaging>

<name>ShinyProxy</name>
Expand All @@ -26,7 +26,7 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<containerproxy.version>0.8.7</containerproxy.version>
<containerproxy.version>0.8.8</containerproxy.version>
<resource.delimiter>&amp;</resource.delimiter>
</properties>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* ShinyProxy
*
* Copyright (C) 2016-2020 Open Analytics
* Copyright (C) 2016-2021 Open Analytics
*
* ===========================================================================
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* ShinyProxy
*
* Copyright (C) 2016-2020 Open Analytics
* Copyright (C) 2016-2021 Open Analytics
*
* ===========================================================================
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* ShinyProxy
*
* Copyright (C) 2016-2020 Open Analytics
* Copyright (C) 2016-2021 Open Analytics
*
* ===========================================================================
*
Expand Down Expand Up @@ -29,9 +29,13 @@
import java.util.stream.Collectors;

import javax.annotation.PostConstruct;
import javax.inject.Inject;

import eu.openanalytics.containerproxy.util.SessionHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Primary;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;

import com.fasterxml.jackson.core.JsonParseException;
Expand All @@ -56,6 +60,13 @@ public class ShinyProxySpecProvider implements IProxySpecProvider {

private List<ProxySpec> specs = new ArrayList<>();

private static Environment environment;

@Autowired
public void setEnvironment(Environment env){
ShinyProxySpecProvider.environment = env;
}

@PostConstruct
public void afterPropertiesSet() {
this.specs.stream().collect(Collectors.groupingBy(ProxySpec::getId)).forEach((id, duplicateSpecs) -> {
Expand All @@ -75,6 +86,11 @@ public ProxySpec getSpec(String id) {
public void setSpecs(List<ShinyProxySpec> specs) {
this.specs = specs.stream().map(ShinyProxySpecProvider::convert).collect(Collectors.toList());
}

private static String getPublicPath(String appName) {
String contextPath = SessionHelper.getContextPath(environment, true);
return contextPath + "app_direct/" + appName + "/";
}

private static ProxySpec convert(ShinyProxySpec from) {
ProxySpec to = new ProxySpec();
Expand All @@ -100,7 +116,15 @@ private static ProxySpec convert(ShinyProxySpec from) {
ContainerSpec cSpec = new ContainerSpec();
cSpec.setImage(from.getContainerImage());
cSpec.setCmd(from.getContainerCmd());
cSpec.setEnv(from.getContainerEnv());

Map<String, String> env = from.getContainerEnv();
if (env == null) {
env = new HashMap<>();
}

env.put("SHINYPROXY_PUBLIC_PATH", getPublicPath(from.getId()));
cSpec.setEnv(env);

cSpec.setEnvFile(from.getContainerEnvFile());
cSpec.setNetwork(from.getContainerNetwork());
cSpec.setNetworkConnections(from.getContainerNetworkConnections());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* ShinyProxy
*
* Copyright (C) 2016-2020 Open Analytics
* Copyright (C) 2016-2021 Open Analytics
*
* ===========================================================================
*
Expand All @@ -23,6 +23,7 @@
import java.net.HttpURLConnection;
import java.net.URI;
import java.net.URL;
import java.util.Arrays;
import java.util.function.IntPredicate;

import javax.inject.Inject;
Expand Down Expand Up @@ -65,8 +66,9 @@ public boolean testProxy(Proxy proxy) {
URL testURL = new URL(targetURI.toString());
HttpURLConnection connection = ((HttpURLConnection) testURL.openConnection());
connection.setConnectTimeout(timeoutMs);
connection.setInstanceFollowRedirects(false);
int responseCode = connection.getResponseCode();
if (responseCode == 200) return true;
if (Arrays.asList(200, 301, 302, 303, 307, 308).contains(responseCode)) return true;
} catch (Exception e) {
if (i > 1 && log != null) log.warn(String.format("Container unresponsive, trying again (%d/%d): %s", i, maxTries, targetURI));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* ShinyProxy
*
* Copyright (C) 2016-2020 Open Analytics
* Copyright (C) 2016-2021 Open Analytics
*
* ===========================================================================
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* ShinyProxy
*
* Copyright (C) 2016-2020 Open Analytics
* Copyright (C) 2016-2021 Open Analytics
*
* ===========================================================================
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* ShinyProxy
*
* Copyright (C) 2016-2020 Open Analytics
* Copyright (C) 2016-2021 Open Analytics
*
* ===========================================================================
*
Expand All @@ -20,24 +20,23 @@
*/
package eu.openanalytics.shinyproxy.controllers;

import java.util.HashMap;
import java.util.Map;

import javax.inject.Inject;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import eu.openanalytics.containerproxy.model.runtime.Proxy;
import eu.openanalytics.containerproxy.model.runtime.ProxyStatus;
import eu.openanalytics.containerproxy.model.spec.ProxySpec;
import eu.openanalytics.containerproxy.util.ProxyMappingManager;
import eu.openanalytics.containerproxy.util.Retrying;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.support.ServletUriComponentsBuilder;

import eu.openanalytics.containerproxy.model.runtime.Proxy;
import eu.openanalytics.containerproxy.model.runtime.ProxyStatus;
import eu.openanalytics.containerproxy.model.spec.ProxySpec;
import eu.openanalytics.containerproxy.util.ProxyMappingManager;
import eu.openanalytics.containerproxy.util.Retrying;
import javax.inject.Inject;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.Map;

@Controller
public class AppController extends BaseController {
Expand Down Expand Up @@ -125,11 +124,11 @@ private boolean awaitReady(Proxy proxy) {
private String buildContainerPath(HttpServletRequest request) {
String appName = getAppName(request);
if (appName == null) return "";

String queryString = request.getQueryString();

String queryString = ServletUriComponentsBuilder.fromRequest(request).replaceQueryParam("sp_hide_navbar").build().getQuery();

queryString = (queryString == null) ? "" : "?" + queryString;

String containerPath = getContextPath() + "app_direct/" + appName + "/" + queryString;
return containerPath;
return getContextPath() + "app_direct/" + appName + "/" + queryString;
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* ShinyProxy
*
* Copyright (C) 2016-2020 Open Analytics
* Copyright (C) 2016-2021 Open Analytics
*
* ===========================================================================
*
Expand All @@ -28,12 +28,14 @@
import java.util.Base64;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import javax.inject.Inject;
import javax.servlet.http.HttpServletRequest;

import eu.openanalytics.containerproxy.auth.IAuthenticationBackend;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.core.env.Environment;
Expand All @@ -59,7 +61,10 @@ public abstract class BaseController {

@Inject
Environment environment;


@Inject
IAuthenticationBackend authenticationBackend;

private static Logger logger = LogManager.getLogger(BaseController.class);
private static Pattern appPattern = Pattern.compile(".*?/app[^/]*/([^/]*)/?.*");
private static Map<String, String> imageCache = new HashMap<>();
Expand Down Expand Up @@ -106,17 +111,25 @@ protected String getProxyEndpoint(Proxy proxy) {
protected void prepareMap(ModelMap map, HttpServletRequest request) {
map.put("title", environment.getProperty("proxy.title", "ShinyProxy"));
map.put("logo", resolveImageURI(environment.getProperty("proxy.logo-url")));
map.put("showNavbar", !Boolean.valueOf(environment.getProperty("proxy.hide-navbar")));


String hideNavBarParam = request.getParameter("sp_hide_navbar");
if (Objects.equals(hideNavBarParam, "true")) {
map.put("showNavbar", false);
} else {
map.put("showNavbar", !Boolean.parseBoolean(environment.getProperty("proxy.hide-navbar")));
}

map.put("bootstrapCss", "/webjars/bootstrap/3.4.1/css/bootstrap.min.css");
map.put("bootstrapJs", "/webjars/bootstrap/3.4.1/js/bootstrap.min.js");
map.put("jqueryJs", "/webjars/jquery/3.5.0/jquery.min.js");

map.put("cookieJs", "/webjars/js-cookie/2.2.1/js.cookie.min.js");

Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
boolean isLoggedIn = authentication != null && !(authentication instanceof AnonymousAuthenticationToken) && authentication.isAuthenticated();
map.put("isLoggedIn", isLoggedIn);
map.put("isAdmin", userService.isAdmin(authentication));
map.put("isSupportEnabled", isLoggedIn && getSupportAddress() != null);
map.put("logoutUrl", authenticationBackend.getLogoutURL());
}

protected String getSupportAddress() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* ShinyProxy
*
* Copyright (C) 2016-2020 Open Analytics
* Copyright (C) 2016-2021 Open Analytics
*
* ===========================================================================
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* ShinyProxy
*
* Copyright (C) 2016-2020 Open Analytics
* Copyright (C) 2016-2021 Open Analytics
*
* ===========================================================================
*
Expand Down
Loading

0 comments on commit 30675f0

Please sign in to comment.