diff options
author | Herbert Eiselt <herbert.eiselt@highstreet-technologies.com> | 2019-03-12 18:00:21 +0100 |
---|---|---|
committer | Herbert Eiselt <herbert.eiselt@highstreet-technologies.com> | 2019-03-12 18:01:06 +0100 |
commit | 2d4424c28ac35763ef44c42ae2f01664d42b268c (patch) | |
tree | 4e6ebdc2e57c1c8f2c91d3ec094b340c89dfe5c5 /sdnr/wt/odlux/apps | |
parent | caf781999351fc6a3e2acb5b2fe47fe04a291d2d (diff) |
Security provider for UX-Client-Login
Use ODL provided oauth2/token for UX clients
Change-Id: I9f9ae931fc5e74dc13076bd23551d163c0685606
Issue-ID: SDNC-648
Signed-off-by: Herbert Eiselt <herbert.eiselt@highstreet-technologies.com>
Diffstat (limited to 'sdnr/wt/odlux/apps')
5 files changed, 30 insertions, 23 deletions
diff --git a/sdnr/wt/odlux/apps/connectApp/src/services/connectService.ts b/sdnr/wt/odlux/apps/connectApp/src/services/connectService.ts index 91891deb6..aa6512011 100644 --- a/sdnr/wt/odlux/apps/connectApp/src/services/connectService.ts +++ b/sdnr/wt/odlux/apps/connectApp/src/services/connectService.ts @@ -6,7 +6,7 @@ import { requestRest } from '../../../../framework/src/services/restService'; import { Result, HitEntry } from '../../../../framework/src/models/elasticSearch'; -/** +/** * Represents a web api accessor service for all Network Elements actions. */ class ConnectService { @@ -16,7 +16,7 @@ class ConnectService { public async getAllRequiredNetworkElements(): Promise<(RequiredNetworkElementType & { _id: string })[] | null> { const path = 'database/mwtn/required-networkelement/_search'; const query = { "query": { "match_all": {} } }; - + const result = await requestRest<Result<RequiredNetworkElementType>>(path, { method: "POST", body: JSON.stringify(query) }); return result && result.hits && result.hits.hits && result.hits.hits.map(ne => ({ _id: ne._id, @@ -30,7 +30,7 @@ class ConnectService { public async getRequiredNetworkElementByMountId(mountId:string): Promise<(RequiredNetworkElementType & { _id: string }) | null> { const path = `database/mwtn/required-networkelement/${mountId}`; - + const result = await requestRest<HitEntry<RequiredNetworkElementType> & { found: boolean }>(path, { method: "GET" }); return result && result.found && result._source && { _id: result._id, @@ -104,8 +104,8 @@ class ConnectService { /** Get all mounted network elements and fills the property required according to the database contents. */ public async getMountedNetworkElementsList(): Promise<MountedNetworkElementType[] | null> { const path = 'restconf/operational/network-topology:network-topology/topology/topology-netconf'; - - const topologyRequestPomise = requestRest<{ topology: Topology[] | null }>(path, { method: "GET" }, true); + + const topologyRequestPomise = requestRest<{ topology: Topology[] | null }>(path, { method: "GET" }); const requiredNetworkElementsPromise = this.getAllRequiredNetworkElements(); const [netconfResponse, requiredNetworkElements] = await Promise.all([topologyRequestPomise, requiredNetworkElementsPromise]); @@ -122,16 +122,16 @@ class ConnectService { return mountPoints || []; } - /** Get one mounted network element. */ + /** Get one mounted network element. */ public async getMountedNetworkElementByMountId(mountId: string): Promise<MountedNetworkElementType | null> { const path = 'restconf/operational/network-topology:network-topology/topology/topology-netconf/node/' + mountId; - const getMountedNetworkElementByMountIdPromise = requestRest<{ node: TopologyNode[] | null }>(path, { method: "GET" }, true); + const getMountedNetworkElementByMountIdPromise = requestRest<{ node: TopologyNode[] | null }>(path, { method: "GET" }); const getRequiredNetworkElementByMountIdPromise = this.getRequiredNetworkElementByMountId(mountId); const [mountedNetworkElement, requiredNetworkElement] = await Promise.all([getMountedNetworkElementByMountIdPromise, getRequiredNetworkElementByMountIdPromise]); return mountedNetworkElement && mountedNetworkElement.node && ConnectService.mapTopologyNode(mountedNetworkElement.node[0], requiredNetworkElement && requiredNetworkElement.mountId === mountedNetworkElement.node[0]["node-id"] || false) || null; } - + /** Mounts an required network element. */ public async mountNetworkElement(networkElement: RequiredNetworkElementType): Promise<boolean> { const path = 'restconf/config/network-topology:network-topology/topology/topology-netconf/node/' + networkElement.mountId; @@ -154,7 +154,7 @@ class ConnectService { ' <!-- keepalive-delay set to 0 turns off keepalives-->', ' <keepalive-delay xmlns="urn:opendaylight:netconf-node-topology">120</keepalive-delay>', '</node>'].join(''); - + try { const result = await requestRest<string>(path, { method: 'PUT', @@ -163,9 +163,9 @@ class ConnectService { 'Accept': 'application/xml' }, body: mountXml - }, true); + }); // expect an empty answer - return result !== null; + return result !== null; } catch { return false; } @@ -174,7 +174,7 @@ class ConnectService { /** Unmounts a network element by its id. */ public async unmountNetworkElement(mountId: string): Promise<boolean> { const path = 'restconf/config/network-topology:network-topology/topology/topology-netconf/node/' + mountId; - + try { const result = await requestRest<string>(path, { method: 'DELETE', @@ -182,10 +182,10 @@ class ConnectService { 'Content-Type': 'application/xml', 'Accept': 'application/xml' }, - }, true); + }); // expect an empty answer - return result !== null; - + return result !== null; + } catch { return false; } diff --git a/sdnr/wt/odlux/apps/connectApp/src/views/connectView.tsx b/sdnr/wt/odlux/apps/connectApp/src/views/connectView.tsx index b73eb39d7..998618608 100644 --- a/sdnr/wt/odlux/apps/connectApp/src/views/connectView.tsx +++ b/sdnr/wt/odlux/apps/connectApp/src/views/connectView.tsx @@ -37,11 +37,12 @@ class ConnectApplicationComponent extends React.Component<ConnectApplicationComp */ constructor(props: ConnectApplicationComponentProps) { super(props); - + this.state = { activePanel: null }; } + private onTogglePanel = (panelId: PanelId) => { const nextActivePanel = panelId === this.state.activePanel ? null : panelId; this.setState({ @@ -69,7 +70,7 @@ class ConnectApplicationComponent extends React.Component<ConnectApplicationComp render(): JSX.Element { const { activePanel } = this.state; - + return ( <> <Panel activePanel={ activePanel } panelId={ 'RequiredNetworkElements' } onToggle={ this.onTogglePanel } title={ "Required Network Elements" }> @@ -85,6 +86,7 @@ class ConnectApplicationComponent extends React.Component<ConnectApplicationComp ); }; public componentDidMount() { + this.onTogglePanel("RequiredNetworkElements"); this.props.onLoadUnknownNetworkElements(); } } diff --git a/sdnr/wt/odlux/apps/mediatorApp/src/views/mediatorApplication.tsx b/sdnr/wt/odlux/apps/mediatorApp/src/views/mediatorApplication.tsx index 11feb46ae..6b1532cc8 100644 --- a/sdnr/wt/odlux/apps/mediatorApp/src/views/mediatorApplication.tsx +++ b/sdnr/wt/odlux/apps/mediatorApp/src/views/mediatorApplication.tsx @@ -120,7 +120,7 @@ class MediatorApplicationComponent extends React.Component<MediatorApplicationCo <Tooltip title={"Info"} ><IconButton className={classes.button}><InfoIcon /></IconButton></Tooltip> </div> <div className={classes.spacer}> - {process.env.NODE_ENV === "development" ? <Tooltip title={"Edit"} ><IconButton disabled={rowData[BusySymbol]} className={classes.button} onClick={event => this.onOpenEditConfigurationDialog(event, rowData)}><EditIcon /></IconButton></Tooltip> : null} + { process.env.NODE_ENV === "development" ? <Tooltip title={"Edit"} ><IconButton disabled={rowData[BusySymbol]} className={classes.button} onClick={event => this.onOpenEditConfigurationDialog(event, rowData)}><EditIcon /></IconButton></Tooltip> : null} <Tooltip title={"Remove"} ><IconButton disabled={rowData[BusySymbol]} className={classes.button} onClick={event => this.onOpenRemoveConfigutationDialog(event, rowData)}><DeleteIcon /></IconButton></Tooltip> </div> </> @@ -159,8 +159,8 @@ class MediatorApplicationComponent extends React.Component<MediatorApplicationCo private onOpenAddConfigurationDialog = () => { // Tries to determine a free port for netconf listener and snpm listener // it it could not determine free ports the dialog will open any way - // those ports should not be configured from the fontend, furthermore - // the backend should auto configure them and tell the user the result + // those ports should not be configured from the fontend, furthermore + // the backend should auto configure them and tell the user the result // after the creation process. this.setState({ diff --git a/sdnr/wt/odlux/apps/mediatorApp/tsconfig.json b/sdnr/wt/odlux/apps/mediatorApp/tsconfig.json index a66b5d828..b0c9b424d 100644 --- a/sdnr/wt/odlux/apps/mediatorApp/tsconfig.json +++ b/sdnr/wt/odlux/apps/mediatorApp/tsconfig.json @@ -25,6 +25,7 @@ "es2016" ], "types": [ + "node", "prop-types", "react", "react-dom" diff --git a/sdnr/wt/odlux/apps/mediatorApp/webpack.config.js b/sdnr/wt/odlux/apps/mediatorApp/webpack.config.js index 151170b46..94943ecd5 100644 --- a/sdnr/wt/odlux/apps/mediatorApp/webpack.config.js +++ b/sdnr/wt/odlux/apps/mediatorApp/webpack.config.js @@ -126,16 +126,20 @@ module.exports = (env) => { colors: true }, proxy: { + "/oauth2/": { + target: "http://localhost:3000", + secure: false + }, "/database/": { - target: "http://localhost:8181", + target: "http://localhost:3000", secure: false }, "/restconf/": { - target: "http://localhost:8181", + target: "http://localhost:3000", secure: false }, "/help/": { - target: "http://localhost:8181", + target: "http://localhost:3000", secure: false } } |