Skip to content

Commit

Permalink
Merge branch 'release/3.0.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
LEDfan committed Mar 14, 2023
2 parents 7d86138 + b837074 commit fdab820
Show file tree
Hide file tree
Showing 43 changed files with 110 additions and 87 deletions.
3 changes: 2 additions & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ pipeline {
agent {
kubernetes {
yamlFile 'kubernetesPod.yaml'
workspaceVolume dynamicPVC(accessModes: 'ReadWriteOnce', requestsSize: '40Gi')
}
}

Expand All @@ -20,7 +21,7 @@ pipeline {

configFileProvider([configFile(fileId: 'maven-settings-rsb', variable: 'MAVEN_SETTINGS_RSB')]) {

sh 'mvn -B -s $MAVEN_SETTINGS_RSB -U clean deploy'
sh 'mvn -B -s $MAVEN_SETTINGS_RSB -Dmaven.repo.local=/home/jenkins/agent/m2 -U clean deploy'

}
}
Expand Down
36 changes: 23 additions & 13 deletions kubernetesPod.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,30 @@
apiVersion: v1
kind: Pod
metadata:
name: shinyproxy
labels:
ci: shinyproxy-build
spec:
securityContext:
fsGroup: 65534
containers:
- name: containerproxy-build
image: 196229073436.dkr.ecr.eu-west-1.amazonaws.com/openanalytics/containerproxy-build
command:
- cat
tty: true
resources:
requests:
memory: "2Gi"
cpu: "1.0"
limits:
memory: "4Gi"
cpu: "1.5"

- name: containerproxy-build
image: 196229073436.dkr.ecr.eu-west-1.amazonaws.com/openanalytics/containerproxy-build
securityContext:
privileged: true
command: [ "sh" ]
args: [ "/usr/src/app/docker-entrypoint.sh" ]
tty: true
volumeMounts:
- name: workspace-volume
subPath: docker
mountPath: /var/lib/docker
resources:
requests:
ephemeral-storage: "20Gi"
memory: "2Gi"
cpu: "1.0"
limits:
memory: "4Gi"
cpu: "1.5"
ephemeral-storage: "20Gi"
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>3.0.0</version>
<version>3.0.1</version>
<packaging>jar</packaging>

<name>ShinyProxy</name>
Expand All @@ -28,7 +28,7 @@
<java.version>1.8</java.version>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<containerproxy.version>1.0.0</containerproxy.version>
<containerproxy.version>1.0.1</containerproxy.version>
<resource.delimiter>&amp;</resource.delimiter>
</properties>

Expand Down
37 changes: 7 additions & 30 deletions src/main/java/eu/openanalytics/shinyproxy/AppRequestInfo.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* ShinyProxy
*
* Copyright (C) 2016-2021 Open Analytics
* Copyright (C) 2016-2023 Open Analytics
*
* ===========================================================================
*
Expand All @@ -20,9 +20,6 @@
*/
package eu.openanalytics.shinyproxy;

import eu.openanalytics.containerproxy.model.runtime.ParameterValues;
import eu.openanalytics.containerproxy.util.BadRequestException;

import javax.servlet.http.HttpServletRequest;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
Expand All @@ -37,7 +34,6 @@ public class AppRequestInfo {
private final String appInstance;
private final String subPath;
private final String appPath;
private ParameterValues providedParameters = null;

public AppRequestInfo(String appName, String appInstance, String appPath, String subPath) {
this.appName = appName;
Expand All @@ -46,37 +42,26 @@ public AppRequestInfo(String appName, String appInstance, String appPath, String
this.subPath = subPath;
}

public static AppRequestInfo fromRequestOrException(HttpServletRequest request) {
AppRequestInfo result = fromURI(request.getRequestURI());
if (result == null) {
throw new BadRequestException("Error parsing URL.");
}
return result;
public static AppRequestInfo fromRequestOrNull(HttpServletRequest request) {
return fromURI(request.getRequestURI());
}

public static AppRequestInfo fromRequestOrException(HttpServletRequest request, ParameterValues providedParameters) {
AppRequestInfo result = fromRequestOrException(request);
result.setProvidedParameters(providedParameters);
return result;
}


public static AppRequestInfo fromURI(String uri) {
Matcher appMatcher = APP_PATTERN.matcher(uri);
Matcher appInstanceMatcher = APP_INSTANCE_PATTERN.matcher(uri);
if (appInstanceMatcher.matches()) {
String appName = appInstanceMatcher.group(2);
if (appName == null || appName.trim().equals("")) {
throw new BadRequestException("Error parsing URL: name of app not found in URL.");
return null;
}

String appInstance = appInstanceMatcher.group(3);
if (appInstance == null || appInstance.trim().equals("")) {
throw new BadRequestException("Error parsing URL: name of instance not found in URL.");
return null;
}

if (appInstance.length() > 64 || !INSTANCE_NAME_PATTERN.matcher(appInstance).matches()) {
throw new BadRequestException("Error parsing URL: name of instance contains invalid characters or is too long.");
return null;
}

String subPath = appInstanceMatcher.group(4);
Expand All @@ -93,7 +78,7 @@ public static AppRequestInfo fromURI(String uri) {
} else if (appMatcher.matches()) {
String appName = appMatcher.group(2);
if (appName == null || appName.trim().equals("")) {
throw new BadRequestException("Error parsing URL: name of app not found in URL.");
return null;
}

String appInstance = "_";
Expand Down Expand Up @@ -138,12 +123,4 @@ public String getAppPath() {
return appPath;
}

public ParameterValues getProvidedParameters() {
return providedParameters;
}

private void setProvidedParameters(ParameterValues providedParameters) {
this.providedParameters = providedParameters;
}

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* ShinyProxy
*
* Copyright (C) 2016-2021 Open Analytics
* Copyright (C) 2016-2023 Open Analytics
*
* ===========================================================================
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* ShinyProxy
*
* Copyright (C) 2016-2021 Open Analytics
* Copyright (C) 2016-2023 Open Analytics
*
* ===========================================================================
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* ShinyProxy
*
* Copyright (C) 2016-2021 Open Analytics
* Copyright (C) 2016-2023 Open Analytics
*
* ===========================================================================
*
Expand Down Expand Up @@ -137,7 +137,10 @@ public void terminateWrites() throws IOException {
private void updateContentLength(HttpServerExchange exchange, ByteBuffer output) {
long length = output.limit();

exchange.getResponseHeaders().put(Headers.CONTENT_LENGTH, length);
// check works case-insensitive
if (!exchange.getResponseHeaders().contains("Transfer-Encoding")) {
exchange.getResponseHeaders().put(Headers.CONTENT_LENGTH, length);
}

// also update length of ServerFixedLengthStreamSinkConduit
if (next instanceof ServerFixedLengthStreamSinkConduit) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* ShinyProxy
*
* Copyright (C) 2016-2021 Open Analytics
* Copyright (C) 2016-2023 Open Analytics
*
* ===========================================================================
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* ShinyProxy
*
* Copyright (C) 2016-2021 Open Analytics
* Copyright (C) 2016-2023 Open Analytics
*
* ===========================================================================
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* ShinyProxy
*
* Copyright (C) 2016-2021 Open Analytics
* Copyright (C) 2016-2023 Open Analytics
*
* ===========================================================================
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* ShinyProxy
*
* Copyright (C) 2016-2021 Open Analytics
* Copyright (C) 2016-2023 Open Analytics
*
* ===========================================================================
*
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/eu/openanalytics/shinyproxy/Thymeleaf.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* ShinyProxy
*
* Copyright (C) 2016-2021 Open Analytics
* Copyright (C) 2016-2023 Open Analytics
*
* ===========================================================================
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* ShinyProxy
*
* Copyright (C) 2016-2021 Open Analytics
* Copyright (C) 2016-2023 Open Analytics
*
* ===========================================================================
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* ShinyProxy
*
* Copyright (C) 2016-2021 Open Analytics
* Copyright (C) 2016-2023 Open Analytics
*
* ===========================================================================
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* ShinyProxy
*
* Copyright (C) 2016-2021 Open Analytics
* Copyright (C) 2016-2023 Open Analytics
*
* ===========================================================================
*
Expand Down Expand Up @@ -92,7 +92,12 @@ public class AppController extends BaseController {

@RequestMapping(value={"/app_i/*/**", "/app/**"}, method=RequestMethod.GET)
public ModelAndView app(ModelMap map, HttpServletRequest request, HttpServletResponse response) {
AppRequestInfo appRequestInfo = AppRequestInfo.fromRequestOrException(request);
AppRequestInfo appRequestInfo = AppRequestInfo.fromRequestOrNull(request);
if (appRequestInfo == null) {
request.setAttribute(RequestDispatcher.ERROR_STATUS_CODE, HttpStatus.FORBIDDEN.value());
return new ModelAndView("forward:/error");
}

Proxy proxy = findUserProxy(appRequestInfo);

ProxySpec spec = proxyService.getProxySpec(appRequestInfo.getAppName());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* ShinyProxy
*
* Copyright (C) 2016-2021 Open Analytics
* Copyright (C) 2016-2023 Open Analytics
*
* ===========================================================================
*
Expand Down Expand Up @@ -35,8 +35,10 @@
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.inject.Inject;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
Expand All @@ -54,7 +56,12 @@ public class AppDirectController extends BaseController {
@RequestMapping(value = {"/app_direct_i/**", "/app_direct/**"})
public void appDirect(HttpServletRequest request, HttpServletResponse response) throws InvalidParametersException, ServletException, IOException {
// note: app_direct does not support parameters and resume
AppRequestInfo appRequestInfo = AppRequestInfo.fromRequestOrException(request);
AppRequestInfo appRequestInfo = AppRequestInfo.fromRequestOrNull(request);
if (appRequestInfo == null) {
request.setAttribute(RequestDispatcher.ERROR_STATUS_CODE, HttpStatus.FORBIDDEN.value());
request.getRequestDispatcher("/error").forward(request, response);
return;
}

if (appRequestInfo.getSubPath() == null) {
try {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* ShinyProxy
*
* Copyright (C) 2016-2021 Open Analytics
* Copyright (C) 2016-2023 Open Analytics
*
* ===========================================================================
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* ShinyProxy
*
* Copyright (C) 2016-2021 Open Analytics
* Copyright (C) 2016-2023 Open Analytics
*
* ===========================================================================
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* ShinyProxy
*
* Copyright (C) 2016-2021 Open Analytics
* Copyright (C) 2016-2023 Open Analytics
*
* ===========================================================================
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* ShinyProxy
*
* Copyright (C) 2016-2021 Open Analytics
* Copyright (C) 2016-2023 Open Analytics
*
* ===========================================================================
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* ShinyProxy
*
* Copyright (C) 2016-2021 Open Analytics
* Copyright (C) 2016-2023 Open Analytics
*
* ===========================================================================
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* ShinyProxy
*
* Copyright (C) 2016-2021 Open Analytics
* Copyright (C) 2016-2023 Open Analytics
*
* ===========================================================================
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* ShinyProxy
*
* Copyright (C) 2016-2021 Open Analytics
* Copyright (C) 2016-2023 Open Analytics
*
* ===========================================================================
*
Expand Down
Loading

0 comments on commit fdab820

Please sign in to comment.