Add configuration option for Portal security 98/998/2
authorLott, Christopher (cl778h) <cl778h@att.com>
Mon, 23 Sep 2019 15:30:35 +0000 (11:30 -0400)
committerLott, Christopher (cl778h) <cl778h@att.com>
Mon, 23 Sep 2019 15:50:56 +0000 (11:50 -0400)
Create version 1.2.2

Change-Id: Ia3ab2a26f64473c035c20db858140f30d79c09d5
Signed-off-by: Lott, Christopher (cl778h) <cl778h@att.com>
12 files changed:
a1-med-client/pom.xml
anr-xapp-client/pom.xml
app-mgr-client/pom.xml
docs/release-notes.rst
e2-mgr-client/pom.xml
pom.xml
webapp-backend/pom.xml
webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/DashboardApplication.java
webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/config/WebSecurityConfiguration.java
webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/portalapi/PortalAuthenticationFilter.java
webapp-backend/src/main/resources/application.properties
webapp-frontend/pom.xml

index 5615ed4..d1dbf5c 100644 (file)
@@ -25,7 +25,7 @@ limitations under the License.
        <parent>
                <groupId>org.o-ran-sc.portal.ric-dashboard</groupId>
                <artifactId>ric-dash-parent</artifactId>
-               <version>1.2.1-SNAPSHOT</version>
+               <version>1.2.2-SNAPSHOT</version>
        </parent>
        <!-- This groupId will NOT allow deployment in LF -->
        <groupId>org.o-ran-sc.ric.plt.a1med.client</groupId>
index 137985a..05cddf9 100644 (file)
@@ -25,7 +25,7 @@ limitations under the License.
        <parent>
                <groupId>org.o-ran-sc.portal.ric-dashboard</groupId>
                <artifactId>ric-dash-parent</artifactId>
-               <version>1.2.1-SNAPSHOT</version>
+               <version>1.2.2-SNAPSHOT</version>
        </parent>
        <!-- This groupId will NOT allow deployment in LF -->
        <groupId>org.o-ran-sc.ric.xapp.anr.client</groupId>
index 4efb783..d27f10c 100644 (file)
@@ -25,7 +25,7 @@ limitations under the License.
        <parent>
                <groupId>org.o-ran-sc.portal.ric-dashboard</groupId>
                <artifactId>ric-dash-parent</artifactId>
-               <version>1.2.1-SNAPSHOT</version>
+               <version>1.2.2-SNAPSHOT</version>
        </parent>
        <!-- This groupId will NOT allow deployment in LF -->
        <groupId>org.o-ran-sc.ric.plt.appmgr.client</groupId>
index 9d6442b..b574db3 100644 (file)
@@ -19,9 +19,9 @@
 RIC Dashboard Release Notes
 ===========================
 
-Version 1.2.?, ? 2019
--------------------------
-* Add EPSDK-FW user management and Portal security
+Version 1.2.2, 23 Sep 2019
+--------------------------
+* Supoprt Portal security using EPSDK-FW cookie and user management
 
 Version 1.2.1, 20 Sep 2019
 --------------------------
index 9082674..723b4ab 100644 (file)
@@ -25,7 +25,7 @@ limitations under the License.
        <parent>
                <groupId>org.o-ran-sc.portal.ric-dashboard</groupId>
                <artifactId>ric-dash-parent</artifactId>
-               <version>1.2.1-SNAPSHOT</version>
+               <version>1.2.2-SNAPSHOT</version>
        </parent>
        <!-- This groupId will NOT allow deployment in LF -->
        <groupId>org.o-ran-sc.ric.plt.e2mgr.client</groupId>
diff --git a/pom.xml b/pom.xml
index 61f3f95..4109bdc 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -33,7 +33,7 @@ limitations under the License.
        <artifactId>ric-dash-parent</artifactId>
        <name>RIC Dashboard project</name>
        <packaging>pom</packaging>
-       <version>1.2.1-SNAPSHOT</version>
+       <version>1.2.2-SNAPSHOT</version>
        <properties>
                <java.version>11</java.version>
                <!-- Properties for the license-maven-plugin in child POMs -->
index 4923794..e008f8b 100644 (file)
@@ -25,7 +25,7 @@ limitations under the License.
        <parent>
                <groupId>org.o-ran-sc.portal.ric-dashboard</groupId>
                <artifactId>ric-dash-parent</artifactId>
-               <version>1.2.1-SNAPSHOT</version>
+               <version>1.2.2-SNAPSHOT</version>
        </parent>
        <artifactId>ric-dash-be</artifactId>
        <name>RIC Dashboard Webapp backend</name>
@@ -292,8 +292,6 @@ limitations under the License.
                                                                        <descriptorRef>artifact</descriptorRef>
                                                                </assembly>
                                                                <runCmds>
-                                                                       <!-- Include debug tool for limited network -->
-                                                                       <runCmd><![CDATA[apt-get update && apt-get -y install curl]]></runCmd>
                                                                        <!-- Ensure logs dir exists and is world writable -->
                                                                        <runCmd>mkdir /logs</runCmd>
                                                                        <runCmd>chmod -R 777 /logs</runCmd>
index 4819e34..fb09ee7 100644 (file)
@@ -20,7 +20,6 @@
 package org.oransc.ric.portal.dashboard;
 
 import java.io.IOException;
-import java.io.InputStream;
 import java.lang.invoke.MethodHandles;
 
 import org.slf4j.Logger;
@@ -36,20 +35,9 @@ public class DashboardApplication {
 
        private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
 
-       // Unfortunately these names are not available as constants
-       private static final String[] propertyFiles = { "ESAPI.properties", "key.properties", "portal.properties",
-                       "validation.properties" };
-
        public static void main(String[] args) throws IOException {
                SpringApplication.run(DashboardApplication.class, args);
-               for (String pf : propertyFiles) {
-                       InputStream in = MethodHandles.lookup().lookupClass().getClassLoader().getResourceAsStream(pf);
-                       if (in == null)
-                               logger.warn("Failed to find property file on classpath: {}", pf);
-                       else
-                               in.close();
-               }
-               // Force this onto the console by using level WARN
+               // Ensure this appears on the console by using level WARN
                logger.warn("main: version '{}' successful start",
                                getImplementationVersion(MethodHandles.lookup().lookupClass()));
        }
index 4e1ddb4..686b9cb 100644 (file)
@@ -61,8 +61,8 @@ public class WebSecurityConfiguration extends WebSecurityConfigurerAdapter {
 
        // Although constructor arguments are recommended over field injection,
        // this results in fewer lines of code.
-       @Value("${userfile}")
-       private String userFilePath;
+       @Value("${portalapi.security}")
+       private Boolean portalapiSecurity;
        @Value("${portalapi.appname}")
        private String appName;
        @Value("${portalapi.username}")
@@ -73,6 +73,8 @@ public class WebSecurityConfiguration extends WebSecurityConfigurerAdapter {
        private String decryptor;
        @Value("${portalapi.usercookie}")
        private String userCookie;
+       @Value("${userfile}")
+       private String userFilePath;
 
        protected void configure(HttpSecurity http) throws Exception {
                logger.debug("configure: portalapi.username {}", userName);
@@ -138,8 +140,8 @@ public class WebSecurityConfiguration extends WebSecurityConfigurerAdapter {
        public PortalAuthenticationFilter portalAuthenticationFilterBean()
                        throws ClassNotFoundException, InstantiationException, IllegalAccessException, IOException,
                        IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
-               PortalAuthenticationFilter portalAuthenticationFilter = new PortalAuthenticationFilter(portalAuthManagerBean(),
-                               dashboardUserManagerBean());
+               PortalAuthenticationFilter portalAuthenticationFilter = new PortalAuthenticationFilter(portalapiSecurity,
+                               portalAuthManagerBean(), dashboardUserManagerBean());
                return portalAuthenticationFilter;
        }
 
index d69d816..18668f3 100644 (file)
@@ -20,6 +20,7 @@
 package org.oransc.ric.portal.dashboard.portalapi;
 
 import java.io.IOException;
+import java.io.InputStream;
 import java.io.UnsupportedEncodingException;
 import java.lang.invoke.MethodHandles;
 import java.net.URLEncoder;
@@ -76,15 +77,39 @@ public class PortalAuthenticationFilter implements Filter {
 
        private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
 
+       // Unfortunately these names are not available as constants
+       private static final String[] securityPropertyFiles = { "ESAPI.properties", "key.properties", "portal.properties",
+                       "validation.properties" };
+
        public static final String REDIRECT_URL_KEY = "redirectUrl";
 
+       private final boolean enforcePortalSecurity;
        private final PortalAuthManager authManager;
 
        private final DashboardUserManager userManager;
 
-       public PortalAuthenticationFilter(PortalAuthManager authManager, DashboardUserManager userManager) {
+       public PortalAuthenticationFilter(boolean portalSecurity, PortalAuthManager authManager,
+                       DashboardUserManager userManager) {
+               this.enforcePortalSecurity = portalSecurity;
                this.authManager = authManager;
                this.userManager = userManager;
+               if (portalSecurity) {
+                       // Throw if security is requested and prerequisites are not met
+                       for (String pf : securityPropertyFiles) {
+                               InputStream in = MethodHandles.lookup().lookupClass().getClassLoader().getResourceAsStream(pf);
+                               if (in == null) {
+                                       String msg = "Failed to find property file on classpath: " + pf;
+                                       logger.error(msg);
+                                       throw new RuntimeException(msg);
+                               } else {
+                                       try {
+                                               in.close();
+                                       } catch (IOException ex) {
+                                               logger.warn("Failed to close stream", ex);
+                                       }
+                               }
+                       }
+               }
        }
 
        @Override
@@ -102,13 +127,23 @@ public class PortalAuthenticationFilter implements Filter {
                // No resources to release
        }
 
+       /**
+        * Requests for pages ignored in the web security config do not hit this filter.
+        */
+       @Override
+       public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)
+                       throws IOException, ServletException {
+               if (enforcePortalSecurity)
+                       doFilterEPSDKFW(req, res, chain);
+               else
+                       doFilterMockUserAdminRole(req, res, chain);
+       }
+
        /*
         * Populates security context with a mock user in the admin role.
         * 
-        * TODO: AUTH
         */
-       @Override
-       public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)
+       private void doFilterMockUserAdminRole(ServletRequest req, ServletResponse res, FilterChain chain)
                        throws IOException, ServletException {
                Authentication auth = SecurityContextHolder.getContext().getAuthentication();
                if (auth == null || auth.getAuthorities().isEmpty()) {
@@ -134,12 +169,9 @@ public class PortalAuthenticationFilter implements Filter {
 
        /*
         * Checks for valid cookies and allows request to be served if found; redirects
-        * to Portal otherwise. Requests for pages ignored in the web security config do
-        * not hit this filter.
-        * 
-        * TODO: AUTH
+        * to Portal otherwise.
         */
-       public void doFilter_EPSDKFW(ServletRequest req, ServletResponse res, FilterChain chain)
+       private void doFilterEPSDKFW(ServletRequest req, ServletResponse res, FilterChain chain)
                        throws IOException, ServletException {
                logger.debug("doFilter {}", req);
                HttpServletRequest request = (HttpServletRequest) req;
index 4c33d34..45eb669 100644 (file)
@@ -28,6 +28,8 @@ server.port = 8080
 # use a persistent volume in a K8S deployment
 userfile = users.json
 
+# boolean flag whether to enforce Portal user and roles on requests
+portalapi.security = false
 # class that decrypts ciphertext from Portal
 portalapi.decryptor = org.oransc.ric.portal.dashboard.portalapi.PortalSdkDecryptorAes
 # name of request cookie with user ID
index 7077e94..8080a0f 100644 (file)
@@ -25,7 +25,7 @@ limitations under the License.
        <parent>
                <groupId>org.o-ran-sc.portal.ric-dashboard</groupId>
                <artifactId>ric-dash-parent</artifactId>
-               <version>1.2.1-SNAPSHOT</version>
+               <version>1.2.2-SNAPSHOT</version>
        </parent>
        <artifactId>ric-dash-fe</artifactId>
        <name>RIC Dashboard Webapp frontend</name>