Fix the userInfo 07/94307/1
authorsebdet <sebastien.determe@intl.att.com>
Mon, 26 Aug 2019 21:29:11 +0000 (14:29 -0700)
committersebdet <sebastien.determe@intl.att.com>
Mon, 26 Aug 2019 21:29:11 +0000 (14:29 -0700)
Fix user Info window, now clicking on the user name make it appears +
attempt to add a logout

Issue-ID: CLAMP-393
Change-Id: I82686a848f7ccae95c1eab22f1923a8821ba76b1
Signed-off-by: sebdet <sebastien.determe@intl.att.com>
src/main/java/org/onap/clamp/clds/config/DefaultUserConfiguration.java
src/main/resources/application-noaaf.properties
ui-react/package.json
ui-react/src/LoopUI.js
ui-react/src/api/UserService.js
ui-react/src/components/dialogs/UserInfo.js
ui-react/src/index.js

index a8ff120..9d4e7d0 100644 (file)
@@ -75,8 +75,10 @@ public class DefaultUserConfiguration extends WebSecurityConfigurerAdapter {
     protected void configure(HttpSecurity http) {
         try {
             http.csrf().disable().httpBasic().and().authorizeRequests().antMatchers("/restservices/clds/v1/user/**")
-            .authenticated().anyRequest().permitAll().and().logout().and().sessionManagement().maximumSessions(1)
-            .and().invalidSessionUrl("/designer/timeout.html");
+                    .authenticated().anyRequest().permitAll().and().logout()
+                    .logoutUrl("/restservices/clds/v1/user/logout").logoutSuccessUrl("/index.html")
+                    .invalidateHttpSession(true).deleteCookies("JSESSIONID").and().sessionManagement()
+                    .maximumSessions(1);
 
         } catch (Exception e) {
             logger.error(SETUP_WEB_USERS_EXCEPTION_MSG, e);
@@ -105,7 +107,7 @@ public class DefaultUserConfiguration extends WebSecurityConfigurerAdapter {
             }
             for (CldsUser user : usersList) {
                 auth.inMemoryAuthentication().withUser(user.getUser()).password(user.getPassword())
-                .authorities(user.getPermissionsString()).and().passwordEncoder(passwordEncoder);
+                        .authorities(user.getPermissionsString()).and().passwordEncoder(passwordEncoder);
             }
         } catch (Exception e) {
             logger.error(SETUP_WEB_USERS_EXCEPTION_MSG, e);
@@ -118,8 +120,7 @@ public class DefaultUserConfiguration extends WebSecurityConfigurerAdapter {
      * CldsUser.
      *
      * @return The array of CldsUser
-     * @throws IOException
-     *         In case of the file is not found
+     * @throws IOException In case of the file is not found
      */
     private CldsUser[] loadUsers() throws IOException {
         logger.info("Load from clds-users.properties");
@@ -134,7 +135,7 @@ public class DefaultUserConfiguration extends WebSecurityConfigurerAdapter {
             return new BCryptPasswordEncoder(cldsBcryptEncoderStrength);
         } else {
             throw new CldsConfigException(
-                "Invalid clamp.config.security.encoder value. 'bcrypt' is the only option at this time.");
+                    "Invalid clamp.config.security.encoder value. 'bcrypt' is the only option at this time.");
         }
     }
 }
\ No newline at end of file
index 52f79be..cec0257 100644 (file)
@@ -2,7 +2,7 @@
 # ============LICENSE_START=======================================================
 # ONAP CLAMP
 # ================================================================================
-# Copyright (C) 2017-2018 AT&T Intellectual Property. All rights
+# Copyright (C) 2017-2019 AT&T Intellectual Property. All rights
 #                             reserved.
 # ================================================================================
 # Licensed under the Apache License, Version 2.0 (the "License");
@@ -51,7 +51,21 @@ info.build.version=@project.version@
 ### server.ssl.key-store=file:/tmp/mykey.jks
 ### server.ssl.key-store-password=mypass
 ### server.ssl.key-password=mypass
-server.port=8080
+server.port=8443
+## Config part for Server certificates
+# Can be a classpath parameter instead of file:/
+server.ssl.key-store=classpath:/clds/aaf/org.onap.clamp.p12
+server.ssl.key-store-password=China in the Spring
+server.ssl.key-password=China in the Spring
+server.ssl.key-store-type=PKCS12
+server.ssl.key-alias=clamp@clamp.onap.org
+
+## Config part for Client certificates
+server.ssl.client-auth=want
+server.ssl.trust-store=classpath:/clds/aaf/truststoreONAPall.jks
+server.ssl.trust-store-password=changeit
+
+#server.http-to-https-redirection.port=8080
 
 server.servlet.context-path=/
 #Modified engine-rest applicationpath
@@ -141,6 +155,7 @@ clamp.config.policy.api.password=zb!XztG34
 clamp.config.policy.pap.url=http4://policy.api.simpledemo.onap.org:6969
 clamp.config.policy.pap.userName=healthcheck
 clamp.config.policy.pap.password=zb!XztG34
+
 clamp.config.policy.pdpUrl1=http://policy.api.simpledemo.onap.org:8081/pdp/ , testpdp, alpha123
 clamp.config.policy.pdpUrl2=http://policy.api.simpledemo.onap.org:8081/pdp/ , testpdp, alpha123
 clamp.config.policy.papUrl=http://policy.api.simpledemo.onap.org:8081/pap/ , testpap, alpha123
index 358152b..65608be 100644 (file)
@@ -1,6 +1,6 @@
 {
   "name": "onap-clamp-ui",
-  "version": "4.1.0-SNAPSHOT",
+  "version": "4.1.1-SNAPSHOT",
   "description": "ONAP Clamp Loop Designer UI",
   "author": "ONAP Clamp Team",
   "license": "Apache-2.0",
@@ -9,7 +9,7 @@
     "registry": "https://nexus3.onap.org/repository/npm.snapshot/"
   },
   "main": "index.js",
-  "proxy": "https://localhost:8080",
+  "proxy": "https://localhost:8443",
   "scripts": {
     "start": "react-scripts start",
     "build": "react-scripts build",
index 9389ad6..fb595de 100644 (file)
@@ -106,6 +106,7 @@ export default class LoopUI extends React.Component {
        constructor() {
                super();
                this.getUser = this.getUser.bind(this);
+               this.logout = this.logout.bind(this);
                this.updateLoopCache = this.updateLoopCache.bind(this);
                this.loadLoop = this.loadLoop.bind(this);
                this.closeLoop = this.closeLoop.bind(this);
@@ -120,6 +121,14 @@ export default class LoopUI extends React.Component {
                        this.setState({ userName: user })
                });
        }
+       
+       logout() {
+               UserService.logout().then(user => {
+                       this.setState({ userName: user });
+                       window.location.reload();
+               });
+               
+       }
 
        renderMenuNavBar() {
                return (
@@ -205,8 +214,8 @@ export default class LoopUI extends React.Component {
                this.setState({ loopCache: new LoopCache({}), loopName: LoopUI.defaultLoopName });
                this.props.history.push('/');
        }
-       
- render() {
+
      render() {
                return (
                                <StyledMainDiv id="main_div">
                                <Route path="/operationalPolicyModal"
@@ -223,7 +232,8 @@ export default class LoopUI extends React.Component {
                                <Route path="/undeploy" render={(routeProps) => (<PerformAction {...routeProps} loopAction="undeploy" loopCache={this.getLoopCache()} updateLoopFunction={this.updateLoopCache}/>)} />
                                <Route path="/deploy" render={(routeProps) => (<DeployLoop {...routeProps} loopCache={this.getLoopCache()} updateLoopFunction={this.updateLoopCache}/>)} />
                                <Route path="/refreshStatus" render={(routeProps) => (<RefreshStatus {...routeProps} loopCache={this.getLoopCache()} updateLoopFunction={this.updateLoopCache}/>)} />
-                                       <GlobalClampStyle />
+                               <Route path="/logout" render={this.logout} />
+                               <GlobalClampStyle />
                                        {this.renderNavBar()}
                                        {this.renderLoopViewer()}
                                </StyledMainDiv>
index be21e69..37ec73d 100644 (file)
@@ -47,6 +47,31 @@ export default class UserService {
                        return UserService.notLoggedUserName;
                });
        }
+       
+       static logout() {
+               return fetch('/restservices/clds/v1/user/logout', {
+                       method: 'POST',
+                       credentials: 'same-origin',
+               })
+               .then(function (response) {
+                       console.debug("logout response received, status code:", response.status);
+                       if (response.ok) {
+                               return response.text();
+                       } else {
+                               console.error("logout response is nok");
+                               return UserService.notLoggedUserName;
+                       }
+               })
+               .then(function (data) {
+                       console.info ("User disconnected:",data)
+                       return data;
+               })
+               .catch(function(error) {
+                       console.warn("logout error received, user set to: ",UserService.notLoggedUserName);
+                       console.error("logout error:",error);
+                       return UserService.notLoggedUserName;
+               });
+       }
 
        static getUserInfo() {
                return fetch('/restservices/clds/v1/clds/cldsInfo', {
index b8d68b8..7d81b38 100644 (file)
@@ -39,7 +39,6 @@ export default class UserInfo extends React.Component {
                super(props, context);
 
                this.handleClose = this.handleClose.bind(this);
-               this.initialValues = this.initialValues.bind(this);
                this.renderReadTemplatePermission = this.renderReadTemplatePermission.bind(this);
                this.renderReadModelPermission = this.renderReadModelPermission.bind(this);
                this.renderReadToscaPermission = this.renderReadToscaPermission.bind(this);
@@ -49,23 +48,15 @@ export default class UserInfo extends React.Component {
                this.renderUserName = this.renderUserName.bind(this);
                this.state = {
                        show: true,
-                       userInfo: {permissionReadTemplate: true,
-                                               permissionReadCl: true,
-                                               permissionReadTosca: true,
-                                               permissionUpdateCl: true,
-                                               permissionUpdateTemplate: true,
-                                               permissionUpdateTosca: true,
-                                               userName: 'admin',
-                                               cldsVersion: '1.0.0'
-                                               }
+                       userInfo: {}
                };
-
        }
-       initialValues() {
+       componentWillMount() {
                UserService.getUserInfo().then(userInfo => {
                        this.setState({ userInfo: userInfo })
                });
        }
+
        handleClose() {
                        this.props.history.push('/');
        }
@@ -127,7 +118,7 @@ export default class UserInfo extends React.Component {
        }
        render() {
                return (
-                       <ModalStyled size="lg"  show={this.state.show} onHide={this.handleClose} onEntered={this.initialValues}>
+                       <ModalStyled size="lg"  show={this.state.show} onHide={this.handleClose}>
                                <Modal.Header closeButton>
                                        <Modal.Title>User Info</Modal.Title>
                                </Modal.Header>
index cbbdc65..dd83096 100644 (file)
 import React from 'react';
 import ReactDOM from 'react-dom';
 import OnapClamp from './OnapClamp';
-import { Route, BrowserRouter } from 'react-router-dom'
+import { Route, MemoryRouter } from 'react-router-dom'
 
 
 const routing = (
-       <BrowserRouter forceRefresh={false}>
+       <MemoryRouter forceRefresh={false}>
                <Route path="/" component={OnapClamp}/>
-       </BrowserRouter>
+       </MemoryRouter>
 );
 
 export var mainClamp = ReactDOM.render(