You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by ah...@apache.org on 2020/01/28 06:17:16 UTC

[isis] branch master updated (34c50f5 -> 47a76dd)

This is an automated email from the ASF dual-hosted git repository.

ahuber pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git.


    from 34c50f5  ISIS-2158: IsisPermission: clean-up thread-local
     new 2680f78  ISIS-2158: make the generated swagger-spec context-path aware
     new 47a76dd  ISIS-2158: RO: allows the authentication strategy to be configured

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../isis/core/config/RestEasyConfiguration.java    | 12 +++++
 .../webmodule/WebModuleJaxrsResteasy4.java         | 58 ++++++++++++----------
 .../service/swagger/SwaggerServiceDefault.java     | 16 ++++--
 .../src/main/resources/swagger-ui/index.thtml      |  1 +
 4 files changed, 56 insertions(+), 31 deletions(-)


[isis] 01/02: ISIS-2158: make the generated swagger-spec context-path aware

Posted by ah...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ahuber pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git

commit 2680f78535ed381b178ba28ae9377eb5282b5194
Author: Andi Huber <ah...@apache.org>
AuthorDate: Tue Jan 28 07:13:21 2020 +0100

    ISIS-2158: make the generated swagger-spec context-path aware
---
 .../rendering/service/swagger/SwaggerServiceDefault.java | 16 ++++++++++++----
 .../viewer/src/main/resources/swagger-ui/index.thtml     |  1 +
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/viewers/restfulobjects/rendering/src/main/java/org/apache/isis/viewer/restfulobjects/rendering/service/swagger/SwaggerServiceDefault.java b/viewers/restfulobjects/rendering/src/main/java/org/apache/isis/viewer/restfulobjects/rendering/service/swagger/SwaggerServiceDefault.java
index 4ae749a..0fa6739 100644
--- a/viewers/restfulobjects/rendering/src/main/java/org/apache/isis/viewer/restfulobjects/rendering/service/swagger/SwaggerServiceDefault.java
+++ b/viewers/restfulobjects/rendering/src/main/java/org/apache/isis/viewer/restfulobjects/rendering/service/swagger/SwaggerServiceDefault.java
@@ -28,9 +28,13 @@ import org.springframework.stereotype.Service;
 
 import org.apache.isis.applib.annotation.OrderPrecedence;
 import org.apache.isis.applib.services.swagger.SwaggerService;
+import org.apache.isis.core.commons.internal.base._Strings;
 import org.apache.isis.core.config.RestEasyConfiguration;
+import org.apache.isis.core.config.viewer.wicket.WebAppContextPath;
 import org.apache.isis.viewer.restfulobjects.rendering.service.swagger.internal.SwaggerSpecGenerator;
 
+import lombok.val;
+
 @Service
 @Named("isisMetaModel.swaggerServiceDefault")
 @Order(OrderPrecedence.MIDPOINT)
@@ -39,16 +43,20 @@ import org.apache.isis.viewer.restfulobjects.rendering.service.swagger.internal.
 public class SwaggerServiceDefault implements SwaggerService {
 
     private final SwaggerSpecGenerator swaggerSpecGenerator;
-    private final RestEasyConfiguration restEasyConfiguration;
     private final String basePath;
 
     @Inject
     public SwaggerServiceDefault(
             final SwaggerSpecGenerator swaggerSpecGenerator,
-            final RestEasyConfiguration restEasyConfiguration) {
+            final RestEasyConfiguration restEasyConfiguration,
+            final WebAppContextPath webAppContextPath) {
+        
         this.swaggerSpecGenerator = swaggerSpecGenerator;
-        this.restEasyConfiguration = restEasyConfiguration;
-        basePath = this.restEasyConfiguration.getJaxrs().getDefaultPath() + "/";
+        
+        val restfulPath = restEasyConfiguration.getJaxrs().getDefaultPath();
+        val restfulBase = webAppContextPath.prependContextPath(restfulPath);
+        
+        this.basePath = _Strings.suffix(restfulBase, "/");
     }
 
     @Override
diff --git a/viewers/restfulobjects/viewer/src/main/resources/swagger-ui/index.thtml b/viewers/restfulobjects/viewer/src/main/resources/swagger-ui/index.thtml
index b4ef86c..ea39b68 100644
--- a/viewers/restfulobjects/viewer/src/main/resources/swagger-ui/index.thtml
+++ b/viewers/restfulobjects/viewer/src/main/resources/swagger-ui/index.thtml
@@ -31,6 +31,7 @@
   </head>
 
   <body>
+  	<!-- template variables are filled in by the TemplateResourceServlet -->
   
     <div id="swagger-ui"></div>
 


[isis] 02/02: ISIS-2158: RO: allows the authentication strategy to be configured

Posted by ah...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ahuber pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git

commit 47a76dd25dd414e1cd18762ecabba092afc3663a
Author: Andi Huber <ah...@apache.org>
AuthorDate: Tue Jan 28 07:17:05 2020 +0100

    ISIS-2158: RO: allows the authentication strategy to be configured
    
    resteasy:
      authentication:
        strategyClassName: my.basicauth.Strategy
---
 .../isis/core/config/RestEasyConfiguration.java    | 12 +++++
 .../webmodule/WebModuleJaxrsResteasy4.java         | 58 ++++++++++++----------
 2 files changed, 43 insertions(+), 27 deletions(-)

diff --git a/core/config/src/main/java/org/apache/isis/core/config/RestEasyConfiguration.java b/core/config/src/main/java/org/apache/isis/core/config/RestEasyConfiguration.java
index f614318..cd45c9c 100644
--- a/core/config/src/main/java/org/apache/isis/core/config/RestEasyConfiguration.java
+++ b/core/config/src/main/java/org/apache/isis/core/config/RestEasyConfiguration.java
@@ -20,6 +20,7 @@ package org.apache.isis.core.config;
 
 import java.util.Collections;
 import java.util.Map;
+import java.util.Optional;
 
 import javax.inject.Inject;
 import javax.inject.Named;
@@ -50,6 +51,17 @@ public class RestEasyConfiguration {
     @Inject @Named("resteasy-settings") private Map<String, String> resteasySettings;
     public Map<String, String> getAsMap() { return Collections.unmodifiableMap(resteasySettings); }
 
+      
+    private final Authentication authentication = new Authentication();
+    @Data
+    public static class Authentication {
+        /**
+         * Defaults to 'org.apache.isis.viewer.restfulobjects.viewer.webmodule.auth.AuthenticationSessionStrategyBasicAuth'.
+         */
+        private Optional<String> strategyClassName = Optional.empty();    
+    }
+    
+    
     private final Jaxrs jaxrs = new Jaxrs();
     @Data
     public static class Jaxrs {
diff --git a/viewers/restfulobjects/jaxrs-resteasy-4/src/main/java/org/apache/isis/viewer/restfulobjects/jaxrsresteasy4/webmodule/WebModuleJaxrsResteasy4.java b/viewers/restfulobjects/jaxrs-resteasy-4/src/main/java/org/apache/isis/viewer/restfulobjects/jaxrsresteasy4/webmodule/WebModuleJaxrsResteasy4.java
index f95d249..79f65f2 100644
--- a/viewers/restfulobjects/jaxrs-resteasy-4/src/main/java/org/apache/isis/viewer/restfulobjects/jaxrsresteasy4/webmodule/WebModuleJaxrsResteasy4.java
+++ b/viewers/restfulobjects/jaxrs-resteasy-4/src/main/java/org/apache/isis/viewer/restfulobjects/jaxrsresteasy4/webmodule/WebModuleJaxrsResteasy4.java
@@ -34,13 +34,14 @@ import org.apache.isis.applib.annotation.OrderPrecedence;
 import org.apache.isis.applib.services.inject.ServiceInjector;
 import org.apache.isis.core.commons.collections.Can;
 import org.apache.isis.core.config.RestEasyConfiguration;
+import org.apache.isis.core.webapp.modules.WebModuleAbstract;
+import org.apache.isis.core.webapp.modules.WebModuleContext;
 import org.apache.isis.viewer.restfulobjects.viewer.webmodule.IsisRestfulObjectsSessionFilter;
 import org.apache.isis.viewer.restfulobjects.viewer.webmodule.IsisTransactionFilterForRestfulObjects;
 import org.apache.isis.viewer.restfulobjects.viewer.webmodule.auth.AuthenticationSessionStrategyBasicAuth;
-import org.apache.isis.core.webapp.modules.WebModuleAbstract;
-import org.apache.isis.core.webapp.modules.WebModuleContext;
 
 import lombok.Getter;
+import lombok.val;
 
 /**
  * WebModule that provides the RestfulObjects Viewer.
@@ -100,38 +101,41 @@ public final class WebModuleJaxrsResteasy4 extends WebModuleAbstract {
     @Override
     public Can<ServletContextListener> init(ServletContext ctx) throws ServletException {
 
+        val authenticationSessionStrategyClassName = restEasyConfiguration.getAuthentication().getStrategyClassName()
+                .orElse(AuthenticationSessionStrategyBasicAuth.class.getName());
+        
         registerFilter(ctx, ISIS_SESSION_FILTER_FOR_RESTFUL_OBJECTS, IsisRestfulObjectsSessionFilter.class)
-                .ifPresent(filterReg -> {
-                    // this is mapped to the entire application;
-                    // however the IsisSessionFilter will
-                    // "notice" if the session filter has already been
-                    // executed for the request pipeline, and if so will do nothing
-                    filterReg.addMappingForUrlPatterns(
-                            null,
-                            true,
-                            this.urlPattern);
-
-                    filterReg.setInitParameter(
-                            "authenticationSessionStrategy",
-                            AuthenticationSessionStrategyBasicAuth.class.getName());
-                    filterReg.setInitParameter(
-                            "whenNoSession", // what to do if no session was found ...
-                            "auto"); // ... 401 and a basic authentication challenge if request originates from web browser
-                    filterReg.setInitParameter(
-                            "passThru",
-                            String.join(",",
-                                    this.restfulPath + "swagger",
-                                    this.restfulPath + "health"));
-
-                } );
+        .ifPresent(filterReg -> {
+            // this is mapped to the entire application;
+            // however the IsisSessionFilter will
+            // "notice" if the session filter has already been
+            // executed for the request pipeline, and if so will do nothing
+            filterReg.addMappingForUrlPatterns(
+                    null,
+                    true,
+                    this.urlPattern);
+            
+            filterReg.setInitParameter(
+                    "authenticationSessionStrategy",
+                    authenticationSessionStrategyClassName);
+            filterReg.setInitParameter(
+                    "whenNoSession", // what to do if no session was found ...
+                    "auto"); // ... 401 and a basic authentication challenge if request originates from web browser
+            filterReg.setInitParameter(
+                    "passThru",
+                    String.join(",",
+                            this.restfulPath + "swagger",
+                            this.restfulPath + "health"));
+
+        } );
 
         registerFilter(ctx, ISIS_TRANSACTION_FILTER, IsisTransactionFilterForRestfulObjects.class)
-            .ifPresent(filterReg -> {
+        .ifPresent(filterReg -> {
                 filterReg.addMappingForUrlPatterns(
                         null,
                         true,
                         this.urlPattern);
-            });
+        });
 
 
         return Can.empty(); // registers no listeners