Skip to content

Commit b55e80a

Browse files
committed
Merge branch 'release/0.8.8'
2 parents 31fc5ea + 9b1537c commit b55e80a

File tree

123 files changed

+1786
-636
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

123 files changed

+1786
-636
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
/target/
22
application.yml
33
logs
4+
5+
.idea
6+
*.iml

LICENSE_HEADER

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
ContainerProxy
22

3-
Copyright (C) 2016-2020 Open Analytics
3+
Copyright (C) 2016-2021 Open Analytics
44

55
===========================================================================
66

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<pre>
2-
____ _ _ ____
3-
/ ___|___ _ __ | |_ __ _(_)_ __ ___ _ __| _ \ _ __ _____ ___ _
2+
____ _ _ ____
3+
/ ___|___ _ __ | |_ __ _(_)_ __ ___ _ __| _ \ _ __ _____ ___ _
44
| | / _ \| '_ \| __/ _` | | '_ \ / _ \ '__| |_) | '__/ _ \ \/ / | | |
55
| |__| (_) | | | | || (_| | | | | | __/ | | __/| | | (_) > <| |_| |
66
\____\___/|_| |_|\__\__,_|_|_| |_|\___|_| |_| |_| \___/_/\_\\__, |
7-
|___/
7+
|___/
88

99
</pre>
1010

@@ -18,7 +18,7 @@ It is the engine that powers a.o. [ShinyProxy](https://shinyproxy.io) but can be
1818

1919
Learn more at https://containerproxy.io (in progress)
2020

21-
#### (c) Copyright Open Analytics NV, 2017-2020 - Apache License 2.0
21+
#### (c) Copyright Open Analytics NV, 2017-2021 - Apache License 2.0
2222

2323
## Building from source
2424

doc/api/containerproxy-rest.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
ContainerProxy
44
5-
Copyright (C) 2016-2020 Open Analytics
5+
Copyright (C) 2016-2021 Open Analytics
66
77
===========================================================================
88

pom.xml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55

66
<groupId>eu.openanalytics</groupId>
77
<artifactId>containerproxy</artifactId>
8-
<version>0.8.7</version>
8+
<version>0.8.8</version>
99
<name>ContainerProxy</name>
1010
<packaging>jar</packaging>
1111

1212
<parent>
1313
<groupId>org.springframework.boot</groupId>
1414
<artifactId>spring-boot-starter-parent</artifactId>
15-
<version>2.3.3.RELEASE</version>
15+
<version>2.3.4.RELEASE</version>
1616
<relativePath />
1717
</parent>
1818

@@ -239,8 +239,15 @@
239239
<groupId>mysql</groupId>
240240
<artifactId>mysql-connector-java</artifactId>
241241
</dependency>
242-
243-
242+
243+
<dependency>
244+
<groupId>io.micrometer</groupId>
245+
<artifactId>micrometer-registry-prometheus</artifactId>
246+
</dependency>
247+
<dependency>
248+
<groupId>io.micrometer</groupId>
249+
<artifactId>micrometer-registry-influx</artifactId>
250+
</dependency>
244251

245252
<!-- Kubernetes -->
246253
<dependency>
@@ -252,8 +259,7 @@
252259
<!-- UI frameworks -->
253260
<dependency>
254261
<groupId>org.thymeleaf.extras</groupId>
255-
<artifactId>thymeleaf-extras-springsecurity4</artifactId>
256-
<version>3.0.2.RELEASE</version>
262+
<artifactId>thymeleaf-extras-springsecurity5</artifactId>
257263
</dependency>
258264
<dependency>
259265
<groupId>org.webjars</groupId>

src/main/java/eu/openanalytics/containerproxy/ContainerProxyApplication.java

Lines changed: 49 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* ContainerProxy
33
*
4-
* Copyright (C) 2016-2020 Open Analytics
4+
* Copyright (C) 2016-2021 Open Analytics
55
*
66
* ===========================================================================
77
*
@@ -31,14 +31,20 @@
3131
import org.springframework.boot.actuate.health.HealthIndicator;
3232
import org.springframework.boot.actuate.redis.RedisHealthIndicator;
3333
import org.springframework.boot.autoconfigure.SpringBootApplication;
34+
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
3435
import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory;
3536
import org.springframework.boot.web.server.PortInUseException;
3637
import org.springframework.boot.web.servlet.FilterRegistrationBean;
3738
import org.springframework.context.annotation.Bean;
3839
import org.springframework.context.annotation.ComponentScan;
3940
import org.springframework.core.env.Environment;
4041
import org.springframework.data.redis.connection.RedisConnectionFactory;
41-
import org.springframework.session.data.redis.config.ConfigureRedisAction;
42+
import org.springframework.security.core.session.SessionRegistry;
43+
import org.springframework.security.web.session.HttpSessionEventPublisher;
44+
import org.springframework.session.FindByIndexNameSessionRepository;
45+
import org.springframework.session.Session;
46+
import org.springframework.session.web.http.DefaultCookieSerializer;
47+
import org.springframework.session.security.SpringSessionBackedSessionRegistry;
4248
import org.springframework.web.filter.FormContentFilter;
4349

4450
import javax.annotation.PostConstruct;
@@ -62,6 +68,9 @@ public class ContainerProxyApplication {
6268
@Inject
6369
private ProxyMappingManager mappingManager;
6470

71+
@Inject
72+
private DefaultCookieSerializer defaultCookieSerializer;
73+
6574
private final Logger log = LogManager.getLogger(getClass());
6675

6776
public static void main(String[] args) {
@@ -86,8 +95,12 @@ public static void main(String[] args) {
8695
@PostConstruct
8796
public void init() {
8897
if (environment.getProperty("server.use-forward-headers") != null) {
89-
log.warn("WARNING: Using server.use-forward-headers will not work in this ShinyProxy release. See https://shinyproxy.io/documentation/security/#https-ssl--tls on how to change your configuration.");
98+
log.warn("WARNING: Using server.use-forward-headers will not work in this ShinyProxy release, you need to change your configuration to use another property. See https://shinyproxy.io/documentation/security/#forward-headers on how to change your configuration.");
9099
}
100+
101+
String sameSiteCookie = environment.getProperty("proxy.same-site-cookie", "Lax");
102+
log.debug("Setting sameSiteCookie policy to {}" , sameSiteCookie);
103+
defaultCookieSerializer.setSameSite(sameSiteCookie);
91104
}
92105

93106
@Bean
@@ -134,16 +147,6 @@ public JSR353Module jsr353Module() {
134147
return new JSR353Module();
135148
}
136149

137-
/**
138-
* Compatibility with AWS ElastiCache
139-
*
140-
* @return
141-
*/
142-
@Bean
143-
public static ConfigureRedisAction configureRedisAction() {
144-
return ConfigureRedisAction.NO_OP;
145-
}
146-
147150
@Bean
148151
public HealthIndicator redisSessionHealthIndicator(RedisConnectionFactory rdeRedisConnectionFactory) {
149152
if (Objects.equals(environment.getProperty("spring.session.store-type"), "redis")) {
@@ -166,11 +169,27 @@ public Health health() {
166169
}
167170
}
168171

172+
/**
173+
* This Bean ensures that User Session are properly expired when using Redis for session storage.
174+
*/
175+
@Bean
176+
@ConditionalOnProperty(name = "spring.session.store-type", havingValue = "redis")
177+
public <S extends Session> SessionRegistry sessionRegistry(FindByIndexNameSessionRepository<S> sessionRepository) {
178+
return new SpringSessionBackedSessionRegistry<S>(sessionRepository);
179+
}
180+
181+
@Bean
182+
public HttpSessionEventPublisher httpSessionEventPublisher() {
183+
return new HttpSessionEventPublisher();
184+
}
185+
169186
private static void setDefaultProperties(SpringApplication app) {
170187
Properties properties = new Properties();
171188

172189
// use in-memory session storage by default. Can be overwritten in application.yml
173190
properties.put("spring.session.store-type", "none");
191+
// required for proper working of the SP_USER_INITIATED_LOGOUT session attribute in the UserService
192+
properties.put("spring.session.redis.flush-mode", "IMMEDIATE");
174193

175194
// disable multi-part handling by Spring. We don't need this anywhere in the application.
176195
// When enabled this will cause problems when proxying file-uploads to the shiny apps.
@@ -181,6 +200,22 @@ private static void setDefaultProperties(SpringApplication app) {
181200

182201
properties.put("spring.application.name", "ContainerProxy");
183202

203+
// Metrics configuration
204+
// ====================
205+
206+
// disable all supported exporters by default
207+
// Note: if we upgrade to Spring Boot 2.4.0 we can use properties.put("management.metrics.export.defaults.enabled", "false");
208+
properties.put("management.metrics.export.prometheus.enabled", "false");
209+
properties.put("management.metrics.export.influx.enabled", "false");
210+
// set actuator to port 9090 (can be overwritten)
211+
properties.put("management.server.port", "9090");
212+
// enable prometheus endpoint by default (but not the exporter)
213+
properties.put("management.endpoint.prometheus.enabled", "true");
214+
// include prometheus and health endpoint in exposure
215+
properties.put("management.endpoints.web.exposure.include", "health,prometheus");
216+
217+
// ====================
218+
184219
// Health configuration
185220
// ====================
186221

@@ -190,7 +225,7 @@ private static void setDefaultProperties(SpringApplication app) {
190225
properties.put("management.health.ldap.enabled", false);
191226
// disable default redis health endpoint since it's managed by redisSession
192227
properties.put("management.health.redis.enabled", "false");
193-
// enable Kubernetes porobes
228+
// enable Kubernetes probes
194229
properties.put("management.endpoint.health.probes.enabled", true);
195230

196231
// ====================

src/main/java/eu/openanalytics/containerproxy/ContainerProxyException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* ContainerProxy
33
*
4-
* Copyright (C) 2016-2020 Open Analytics
4+
* Copyright (C) 2016-2021 Open Analytics
55
*
66
* ===========================================================================
77
*

src/main/java/eu/openanalytics/containerproxy/api/BaseController.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* ContainerProxy
33
*
4-
* Copyright (C) 2016-2020 Open Analytics
4+
* Copyright (C) 2016-2021 Open Analytics
55
*
66
* ===========================================================================
77
*
@@ -20,14 +20,32 @@
2020
*/
2121
package eu.openanalytics.containerproxy.api;
2222

23+
import org.springframework.core.env.Environment;
2324
import org.springframework.http.HttpStatus;
25+
import org.springframework.security.authentication.AnonymousAuthenticationToken;
26+
import org.springframework.security.core.Authentication;
27+
import org.springframework.security.core.context.SecurityContextHolder;
28+
import org.springframework.ui.ModelMap;
2429
import org.springframework.web.bind.annotation.ControllerAdvice;
2530
import org.springframework.web.bind.annotation.ExceptionHandler;
2631
import org.springframework.web.bind.annotation.ResponseBody;
2732
import org.springframework.web.bind.annotation.ResponseStatus;
2833

34+
import javax.inject.Inject;
35+
import javax.servlet.http.HttpServletRequest;
36+
2937
public class BaseController {
3038

39+
@Inject
40+
private Environment environment;
41+
42+
protected void prepareMap(ModelMap map) {
43+
map.put("title", environment.getProperty("proxy.title", "ShinyProxy"));
44+
map.put("bootstrapCss", "/webjars/bootstrap/3.4.1/css/bootstrap.min.css");
45+
map.put("bootstrapJs", "/webjars/bootstrap/3.4.1/js/bootstrap.min.js");
46+
map.put("jqueryJs", "/webjars/jquery/3.5.0/jquery.min.js");
47+
}
48+
3149
public static class NotFoundException extends RuntimeException {
3250

3351
private static final long serialVersionUID = 2042632906716154791L;

src/main/java/eu/openanalytics/containerproxy/api/ProxyController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* ContainerProxy
33
*
4-
* Copyright (C) 2016-2020 Open Analytics
4+
* Copyright (C) 2016-2021 Open Analytics
55
*
66
* ===========================================================================
77
*

src/main/java/eu/openanalytics/containerproxy/api/ProxyRouteController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* ContainerProxy
33
*
4-
* Copyright (C) 2016-2020 Open Analytics
4+
* Copyright (C) 2016-2021 Open Analytics
55
*
66
* ===========================================================================
77
*

src/main/java/eu/openanalytics/containerproxy/auth/AuthenticationBackendFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* ContainerProxy
33
*
4-
* Copyright (C) 2016-2020 Open Analytics
4+
* Copyright (C) 2016-2021 Open Analytics
55
*
66
* ===========================================================================
77
*

src/main/java/eu/openanalytics/containerproxy/auth/IAuthenticationBackend.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* ContainerProxy
33
*
4-
* Copyright (C) 2016-2020 Open Analytics
4+
* Copyright (C) 2016-2021 Open Analytics
55
*
66
* ===========================================================================
77
*
@@ -59,7 +59,11 @@ public interface IAuthenticationBackend {
5959
public default String getLogoutSuccessURL() {
6060
return "/login";
6161
}
62-
62+
63+
public default String getLogoutURL() {
64+
return "/logout";
65+
}
66+
6367
public default void customizeContainer(ContainerSpec spec) {
6468
// Default: do nothing.
6569
}

src/main/java/eu/openanalytics/containerproxy/auth/UserLogoutHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* ContainerProxy
33
*
4-
* Copyright (C) 2016-2020 Open Analytics
4+
* Copyright (C) 2016-2021 Open Analytics
55
*
66
* ===========================================================================
77
*
@@ -35,7 +35,7 @@ public class UserLogoutHandler implements LogoutHandler {
3535

3636
@Inject
3737
private UserService userService;
38-
38+
3939
@Override
4040
public void logout(HttpServletRequest request, HttpServletResponse response, Authentication authentication) {
4141
userService.logout(authentication);

0 commit comments

Comments
 (0)