You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dlab.apache.org by bh...@apache.org on 2019/07/25 11:31:32 UTC
[incubator-dlab] 10/12: DLAB-2 disabled gzip handler for guacamole
servlet
This is an automated email from the ASF dual-hosted git repository.
bhliva pushed a commit to branch v2.1.1
in repository https://gitbox.apache.org/repos/asf/incubator-dlab.git
commit 4e70035fc481446185d8dc959884c5b16005805a
Author: bhliva <bo...@epam.com>
AuthorDate: Tue May 7 13:47:24 2019 +0300
DLAB-2 disabled gzip handler for guacamole servlet
---
.../dlab/backendapi/resources/base/KeyResource.java | 4 +---
services/self-service/self-service.yml | 2 --
.../epam/dlab/backendapi/SelfServiceApplication.java | 19 ++++++++++++++++++-
3 files changed, 19 insertions(+), 6 deletions(-)
diff --git a/services/provisioning-service/src/main/java/com/epam/dlab/backendapi/resources/base/KeyResource.java b/services/provisioning-service/src/main/java/com/epam/dlab/backendapi/resources/base/KeyResource.java
index fcacef0..bbff7b9 100644
--- a/services/provisioning-service/src/main/java/com/epam/dlab/backendapi/resources/base/KeyResource.java
+++ b/services/provisioning-service/src/main/java/com/epam/dlab/backendapi/resources/base/KeyResource.java
@@ -46,13 +46,11 @@ public class KeyResource {
private final KeyService keyService;
private final ProvisioningServiceApplicationConfiguration configuration;
- private final String keyContent;
@Inject
public KeyResource(KeyService keyService, ProvisioningServiceApplicationConfiguration configuration) {
this.keyService = keyService;
this.configuration = configuration;
- this.keyContent = keyService.getAdminKey();
}
@@ -69,7 +67,7 @@ public class KeyResource {
@GET
public String getAdminKey(@Auth UserInfo userInfo) {
- return keyContent;
+ return keyService.getAdminKey();
}
private void replaceKeyfile(ReuploadKeyDTO dto) throws IOException {
diff --git a/services/self-service/self-service.yml b/services/self-service/self-service.yml
index 8ae3c02..6e25287 100644
--- a/services/self-service/self-service.yml
+++ b/services/self-service/self-service.yml
@@ -67,8 +67,6 @@ maxSessionDurabilityMilliseconds: 288000000
</#if>
server:
- gzip:
- enabled: false
requestLog:
appenders:
- type: file
diff --git a/services/self-service/src/main/java/com/epam/dlab/backendapi/SelfServiceApplication.java b/services/self-service/src/main/java/com/epam/dlab/backendapi/SelfServiceApplication.java
index 1a8f59b..979464f 100644
--- a/services/self-service/src/main/java/com/epam/dlab/backendapi/SelfServiceApplication.java
+++ b/services/self-service/src/main/java/com/epam/dlab/backendapi/SelfServiceApplication.java
@@ -48,11 +48,15 @@ import io.dropwizard.Application;
import io.dropwizard.assets.AssetsBundle;
import io.dropwizard.forms.MultiPartBundle;
import io.dropwizard.jersey.setup.JerseyEnvironment;
+import io.dropwizard.jetty.BiDiGzipHandler;
import io.dropwizard.setup.Bootstrap;
import io.dropwizard.setup.Environment;
import io.federecio.dropwizard.swagger.SwaggerBundle;
import io.federecio.dropwizard.swagger.SwaggerBundleConfiguration;
import lombok.extern.slf4j.Slf4j;
+import org.eclipse.jetty.server.Handler;
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.server.handler.HandlerWrapper;
import javax.servlet.DispatcherType;
import java.util.EnumSet;
@@ -62,6 +66,7 @@ import java.util.EnumSet;
*/
@Slf4j
public class SelfServiceApplication extends Application<SelfServiceApplicationConfiguration> {
+ private static final String GUACAMOLE_SERVLET_PATH = "/api/tunnel";
private static Injector appInjector;
public static Injector getInjector() {
@@ -110,6 +115,7 @@ public class SelfServiceApplication extends Application<SelfServiceApplicationCo
new RestoreHandlerStartupListener(injector.getInstance(Key.get(RESTService.class,
Names.named(ServiceConsts.PROVISIONING_SERVICE_NAME))));
environment.lifecycle().addServerLifecycleListener(restoreHandlerStartupListener);
+ environment.lifecycle().addServerLifecycleListener(this::disableGzipHandlerForGuacamoleServlet);
environment.lifecycle().manage(injector.getInstance(IndexCreator.class));
environment.lifecycle().manage(injector.getInstance(EnvStatusListener.class));
environment.lifecycle().manage(injector.getInstance(ExploratoryLibCache.class));
@@ -120,7 +126,7 @@ public class SelfServiceApplication extends Application<SelfServiceApplicationCo
final String guacamoleServletName = "GuacamoleServlet";
environment.servlets().addServlet(guacamoleServletName, injector.getInstance(GuacamoleServlet.class))
- .addMapping("/api/tunnel");
+ .addMapping(GUACAMOLE_SERVLET_PATH);
environment.servlets().addFilter("GuacamoleSecurityFilter",
injector.getInstance(GuacamoleSecurityFilter.class))
.addMappingForServletNames(EnumSet.allOf(DispatcherType.class), true, guacamoleServletName);
@@ -169,6 +175,17 @@ public class SelfServiceApplication extends Application<SelfServiceApplicationCo
jersey.register(injector.getInstance(ApplicationSettingResource.class));
}
+ private void disableGzipHandlerForGuacamoleServlet(Server server) {
+ Handler handler = server.getHandler();
+ while (handler instanceof HandlerWrapper) {
+ handler = ((HandlerWrapper) handler).getHandler();
+ if (handler instanceof BiDiGzipHandler) {
+ log.debug("Disabling Gzip handler for guacamole servlet");
+ ((BiDiGzipHandler) handler).setExcludedPaths(GUACAMOLE_SERVLET_PATH);
+ }
+ }
+ }
+
private void applyMongoMigration(SelfServiceApplicationConfiguration configuration) {
final MongoServiceFactory mongoFactory = configuration.getMongoFactory();
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@dlab.apache.org
For additional commands, e-mail: commits-help@dlab.apache.org