Repository: freemarker-online-tester
Updated Branches:
  refs/heads/master 53c267409 -> 62980b666


Prepared for HTTPS and working together with Let's Encrypt certbot


Project: http://git-wip-us.apache.org/repos/asf/freemarker-online-tester/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/freemarker-online-tester/commit/62980b66
Tree: 
http://git-wip-us.apache.org/repos/asf/freemarker-online-tester/tree/62980b66
Diff: 
http://git-wip-us.apache.org/repos/asf/freemarker-online-tester/diff/62980b66

Branch: refs/heads/master
Commit: 62980b666d51018a21f8c18f275b690bddbb4118
Parents: 53c2674
Author: ddekany <[email protected]>
Authored: Tue May 15 20:03:55 2018 +0200
Committer: ddekany <[email protected]>
Committed: Tue May 15 20:03:55 2018 +0200

----------------------------------------------------------------------
 build.gradle                                    |  2 +-
 dependencies.gradle                             |  1 +
 .../dropwizard/FreeMarkerOnlineTester.java      | 17 ++++++++++++---
 .../FreeMarkerOnlineTesterConfiguration.java    | 16 +++++++++++++-
 src/main/resources/freemarker-online.yml        | 23 ++++++++++++++++++--
 5 files changed, 52 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/freemarker-online-tester/blob/62980b66/build.gradle
----------------------------------------------------------------------
diff --git a/build.gradle b/build.gradle
index df3fcae..59d7907 100644
--- a/build.gradle
+++ b/build.gradle
@@ -61,7 +61,7 @@ dependencies {
     compile libraries.dropwizard
     compile libraries.dropwizard_views
     compile libraries.dropwizard_views_freemarker
-    compile libraries.dropwizard_assets
+    compile libraries.dropwizard_configurable_assets
     compile libraries.dropwizard_bundles_redirect
     compile libraries.freemarker
     compile libraries.commonLangs

http://git-wip-us.apache.org/repos/asf/freemarker-online-tester/blob/62980b66/dependencies.gradle
----------------------------------------------------------------------
diff --git a/dependencies.gradle b/dependencies.gradle
index d957ff8..635c92c 100644
--- a/dependencies.gradle
+++ b/dependencies.gradle
@@ -27,6 +27,7 @@ ext.libraries = [
         dropwizard_views: "io.dropwizard:dropwizard-views:$dropwizard_version",
         dropwizard_views_freemarker: 
"io.dropwizard:dropwizard-views-freemarker:$dropwizard_version",
         dropwizard_assets: 
"io.dropwizard:dropwizard-assets:$dropwizard_version",
+        dropwizard_configurable_assets: 
"io.dropwizard-bundles:dropwizard-configurable-assets-bundle:1.0.5",
         dropwizard_bundles_redirect: 
"io.dropwizard-bundles:dropwizard-redirect-bundle:1.2.2",
 
         // App. specific:

http://git-wip-us.apache.org/repos/asf/freemarker-online-tester/blob/62980b66/src/main/java/org/apache/freemarker/onlinetester/dropwizard/FreeMarkerOnlineTester.java
----------------------------------------------------------------------
diff --git 
a/src/main/java/org/apache/freemarker/onlinetester/dropwizard/FreeMarkerOnlineTester.java
 
b/src/main/java/org/apache/freemarker/onlinetester/dropwizard/FreeMarkerOnlineTester.java
index 40dab6e..563720a 100644
--- 
a/src/main/java/org/apache/freemarker/onlinetester/dropwizard/FreeMarkerOnlineTester.java
+++ 
b/src/main/java/org/apache/freemarker/onlinetester/dropwizard/FreeMarkerOnlineTester.java
@@ -26,12 +26,15 @@ import 
org.apache.freemarker.onlinetester.resources.ExecuteApiResource;
 import org.apache.freemarker.onlinetester.resources.WebPageResource;
 import org.apache.freemarker.onlinetester.services.FreeMarkerService;
 
+import com.google.common.collect.ImmutableMap;
+
 import io.dropwizard.Application;
-import io.dropwizard.assets.AssetsBundle;
+import io.dropwizard.bundles.assets.ConfiguredAssetsBundle;
 import io.dropwizard.bundles.redirect.RedirectBundle;
 import io.dropwizard.bundles.redirect.UriRedirect;
 import io.dropwizard.setup.Bootstrap;
 import io.dropwizard.setup.Environment;
+import io.dropwizard.sslreload.SslReloadBundle;
 import io.dropwizard.views.ViewBundle;
 
 public class FreeMarkerOnlineTester extends 
Application<FreeMarkerOnlineTesterConfiguration> {
@@ -61,11 +64,19 @@ public class FreeMarkerOnlineTester extends 
Application<FreeMarkerOnlineTesterCo
                 return config.getViewRendererConfiguration();
             }          
         });
-        bootstrap.addBundle(new AssetsBundle());
+        bootstrap.addBundle(new SslReloadBundle());
+        bootstrap.addBundle(new ConfiguredAssetsBundle(
+                       ImmutableMap.of(
+                                       "/assets/", "/assets/", // css, js, 
images...
+                                       "/letsencrypt-verify", 
"/letsencrypt-verify" // Map to a file outside the jar in the yml!
+                                       )));
         bootstrap.addBundle(new RedirectBundle(
                 new UriRedirect(
                         "http://freemarker-online.kenshoo.com([:/].*)$",
-                        "http://try.freemarker.org$1";)
+                        "http://try.freemarker.org$1";),
+                new UriRedirect(
+                        "http://try.freemarker.apache.org([:/].*)$",
+                        "https://try.freemarker.apache.org$1";)
         ));
     }
 }

http://git-wip-us.apache.org/repos/asf/freemarker-online-tester/blob/62980b66/src/main/java/org/apache/freemarker/onlinetester/dropwizard/FreeMarkerOnlineTesterConfiguration.java
----------------------------------------------------------------------
diff --git 
a/src/main/java/org/apache/freemarker/onlinetester/dropwizard/FreeMarkerOnlineTesterConfiguration.java
 
b/src/main/java/org/apache/freemarker/onlinetester/dropwizard/FreeMarkerOnlineTesterConfiguration.java
index b29622c..f0b9122 100644
--- 
a/src/main/java/org/apache/freemarker/onlinetester/dropwizard/FreeMarkerOnlineTesterConfiguration.java
+++ 
b/src/main/java/org/apache/freemarker/onlinetester/dropwizard/FreeMarkerOnlineTesterConfiguration.java
@@ -24,10 +24,13 @@ import java.util.Map;
 import com.fasterxml.jackson.annotation.JsonProperty;
 
 import io.dropwizard.Configuration;
+import io.dropwizard.bundles.assets.AssetsBundleConfiguration;
+import io.dropwizard.bundles.assets.AssetsConfiguration;
 
-public class FreeMarkerOnlineTesterConfiguration extends Configuration {
+public class FreeMarkerOnlineTesterConfiguration extends Configuration 
implements AssetsBundleConfiguration {
 
     private Map<String, Map<String, String>> viewRendererConfiguration;
+       private AssetsConfiguration assetsConfiguration;
 
        @JsonProperty("viewRendererConfiguration")
     public Map<String, Map<String, String>> getViewRendererConfiguration() {
@@ -39,4 +42,15 @@ public class FreeMarkerOnlineTesterConfiguration extends 
Configuration {
         this.viewRendererConfiguration = viewRendererConfiguration;
     }
     
+    @JsonProperty("assets")
+    @Override
+    public AssetsConfiguration getAssetsConfiguration() {
+      return assetsConfiguration;
+    }
+
+    @JsonProperty("assets")
+       public void setAssetsConfiguration(AssetsConfiguration 
assetsConfiguration) {
+               this.assetsConfiguration = assetsConfiguration;
+       }
+    
 }

http://git-wip-us.apache.org/repos/asf/freemarker-online-tester/blob/62980b66/src/main/resources/freemarker-online.yml
----------------------------------------------------------------------
diff --git a/src/main/resources/freemarker-online.yml 
b/src/main/resources/freemarker-online.yml
index c1268b2..1ffb937 100644
--- a/src/main/resources/freemarker-online.yml
+++ b/src/main/resources/freemarker-online.yml
@@ -22,7 +22,7 @@ logging:
     - type: console
       threshold: ALL
       target: stdout
-#    # For production:
+#    # FOR PRODUCTION:
 #    - type: file
 #      currentLogFilename: /opt/fmonlinetester/var/log/main.log
 #      threshold: ALL
@@ -34,10 +34,29 @@ logging:
 server:
   requestLog:
     appenders: []
+  applicationConnectors:    
+      - type: http
+        port: 8080
+#      # FOR PRODUCTION:
+#      - type: https
+#        port: 8443
+#        keyStorePath: /etc/letsencrypt/live/example.p12
+#        keyStoreType: PKCS12
+#        keyStorePassword: secret
+#        validateCerts: false
+  adminConnectors:
+      # HTTP POST to /tasks/reload-ssl to reload SSL certificates without 
stopping.
+      - type: http
+        port: 8081            
 viewRendererConfiguration:
   freemarker:  # was `.ftl:` before Dropwizard 1.3.0
     incompatibleImprovements: 2.3.28
     locale: en_US
     timeZone: UTC
     outputEncoding: UTF-8
-    templateExceptionHandler: rethrow
\ No newline at end of file
+    templateExceptionHandler: rethrow
+assets:
+  overrides:
+    # Let's Encrypt certbot writes its domain ownership vertification file 
here. It will visit
+    # it from outside when we ask for a new certificate: 
+    /letsencrypt-verify: /opt/fmonlinetester/var/letsencrypt-verify
\ No newline at end of file

Reply via email to