From 8515052e1a6de2de56effbc61c73d3aa80169a93 Mon Sep 17 00:00:00 2001 From: Aijana Schumann Date: Mon, 15 Feb 2021 18:22:28 +0100 Subject: Add OAuth support to odlux Extend odlux to support oauth, support external login provider for sign-in Issue-ID: CCSDK-3167 Signed-off-by: Aijana Schumann Change-Id: Id5772e0026fa7ebda22c41c2620a7868598f41aa --- sdnr/wt/odlux/apps/configurationApp/policies.json | 12 ++++++++ .../configurationApp/src/actions/deviceActions.ts | 5 ++-- .../src/handlers/viewDescriptionHandler.ts | 3 +- sdnr/wt/odlux/apps/configurationApp/src/index.html | 1 + .../src/views/configurationApplication.tsx | 16 ++++++++-- .../odlux/apps/configurationApp/webpack.config.js | 35 ++++++++++++++-------- 6 files changed, 53 insertions(+), 19 deletions(-) create mode 100644 sdnr/wt/odlux/apps/configurationApp/policies.json (limited to 'sdnr/wt/odlux/apps/configurationApp') diff --git a/sdnr/wt/odlux/apps/configurationApp/policies.json b/sdnr/wt/odlux/apps/configurationApp/policies.json new file mode 100644 index 000000000..cd9e9fc15 --- /dev/null +++ b/sdnr/wt/odlux/apps/configurationApp/policies.json @@ -0,0 +1,12 @@ +[ + { + "path": "/**/operations/cluster-admin**", + "actions": { + "get": true, + "post": true, + "put": true, + "patch": true, + "delete": true + } + } +] \ No newline at end of file diff --git a/sdnr/wt/odlux/apps/configurationApp/src/actions/deviceActions.ts b/sdnr/wt/odlux/apps/configurationApp/src/actions/deviceActions.ts index e528effab..d6283852c 100644 --- a/sdnr/wt/odlux/apps/configurationApp/src/actions/deviceActions.ts +++ b/sdnr/wt/odlux/apps/configurationApp/src/actions/deviceActions.ts @@ -35,7 +35,7 @@ export class UpdateDeviceDescription extends Action { } export class UpdatViewDescription extends Action { - constructor (public vPath: string, public viewData: any, public displaySpecification: DisplaySpecification = { displayMode: DisplayModeType.doNotDisplay } ) { + constructor (public vPath: string, public viewData: any, public displaySpecification: DisplaySpecification = { displayMode: DisplayModeType.doNotDisplay }) { super(); } } @@ -437,7 +437,7 @@ export const updateViewActionAsyncCreator = (vPath: string) => async (dispatch: } }); } - + // create display specification const ds: DisplaySpecification = viewElement! && viewElement!.uiType === "rpc" ? { @@ -449,6 +449,7 @@ export const updateViewActionAsyncCreator = (vPath: string) => async (dispatch: displayMode: extractList ? DisplayModeType.displayAsList : DisplayModeType.displayAsObject, viewSpecification: resolveViewDescription(defaultNS, vPath, viewSpecification), keyProperty: isViewElementList(viewElement!) && viewElement.key || undefined, + apidocPath: isViewElementList(viewElement!) && `/apidoc/explorer/index.html?urls.primaryName=$$$standard$$$#/mounted%20${nodeId}%20${viewElement!.module || 'MODULE_NOT_DEFINED'}/$$$action$$$_${dataPath.replace(/^\//,'').replace(/[\/=\-\:]/g,'_')}_${viewElement! != null ? `${viewElement.id.replace(/[\/=\-\:]/g,'_')}_` : '' }` || undefined, }; // update display specification diff --git a/sdnr/wt/odlux/apps/configurationApp/src/handlers/viewDescriptionHandler.ts b/sdnr/wt/odlux/apps/configurationApp/src/handlers/viewDescriptionHandler.ts index 69710b9e9..ea2036415 100644 --- a/sdnr/wt/odlux/apps/configurationApp/src/handlers/viewDescriptionHandler.ts +++ b/sdnr/wt/odlux/apps/configurationApp/src/handlers/viewDescriptionHandler.ts @@ -33,7 +33,8 @@ export type DisplaySpecification = { } | { displayMode: DisplayModeType.displayAsObject | DisplayModeType.displayAsList ; viewSpecification: ViewSpecification; - keyProperty: string | undefined; + keyProperty?: string; + apidocPath?: string; } | { displayMode: DisplayModeType.displayAsRPC; inputViewSpecification?: ViewSpecification; diff --git a/sdnr/wt/odlux/apps/configurationApp/src/index.html b/sdnr/wt/odlux/apps/configurationApp/src/index.html index 759b7b535..78fff78c5 100644 --- a/sdnr/wt/odlux/apps/configurationApp/src/index.html +++ b/sdnr/wt/odlux/apps/configurationApp/src/index.html @@ -19,6 +19,7 @@ connectApp.register(); configurationApp.register(); maintenanceApp.register(); + app("./app.tsx").configureApplication({ authentication:"oauth", enablePolicy: true,}); app("./app.tsx").runApplication(); }); diff --git a/sdnr/wt/odlux/apps/configurationApp/src/views/configurationApplication.tsx b/sdnr/wt/odlux/apps/configurationApp/src/views/configurationApplication.tsx index 45b3081c2..dbaa77874 100644 --- a/sdnr/wt/odlux/apps/configurationApp/src/views/configurationApplication.tsx +++ b/sdnr/wt/odlux/apps/configurationApp/src/views/configurationApplication.tsx @@ -33,6 +33,7 @@ import { ViewSpecification, isViewElementString, isViewElementNumber, isViewElem import Fab from '@material-ui/core/Fab'; import AddIcon from '@material-ui/icons/Add'; +import PostAdd from '@material-ui/icons/PostAdd'; import ArrowBack from '@material-ui/icons/ArrowBack'; import RemoveIcon from '@material-ui/icons/RemoveCircleOutline'; import SaveIcon from '@material-ui/icons/Save'; @@ -545,8 +546,11 @@ class ConfigurationApplicationComponent extends React.Component { this.props.history.push(`${this.props.match.url}${path}`); @@ -558,6 +562,12 @@ class ConfigurationApplicationComponent extends React.Component { + window.open(apiDocPathCreate, '_blank'); + } + }; + const { classes, removeElement } = this.props; const DeleteIconWithConfirmation: React.FC<{ rowData: { [key: string]: any }, onReload: () => void }> = (props) => { @@ -580,7 +590,7 @@ class ConfigurationApplicationComponent extends React.Component[]>((acc, cur) => { const elm = listElements[cur]; if (elm.uiType !== "object" && listData.every(entry => entry[elm.label] != null)) { @@ -790,7 +800,7 @@ class ConfigurationApplicationComponent extends React.Component path.replace(/^([a-z]\:)/, c => c.toUpperCase()))(process.__dirname()); module.exports = (env) => { @@ -127,48 +129,55 @@ module.exports = (env) => { quiet: false, stats: { colors: true + }, + before: function(app, server, compiler) { + app.get('/oauth/policies',(_, res) => res.json(policies)); }, proxy: { "/about": { - // target: "http://10.20.6.29:48181", - target: "http://localhost:8181", + target: "http://localhost:18181", secure: false }, "/yang-schema/": { - target: "http://localhost:8181", + target: "http://localhost:18181", secure: false }, - "/oauth2/": { - // target: "https://10.20.35.188:30205", - target: "http://localhost:8181", + "/oauth/": { + target: "http://localhost:18181", secure: false }, "/database/": { - target: "http://localhost:8181", + target: "http://localhost:18181", secure: false }, "/restconf/": { - target: "http://localhost:8181", + target: "http://localhost:18181", secure: false }, "/rests/": { - target: "http://localhost:8181", + target: "http://localhost:18181", secure: false }, "/help/": { - target: "http://localhost:8181", + target: "http://localhost:18181", secure: false }, "/about/": { - target: "http://localhost:8181", + target: "http://localhost:18181", secure: false }, "/tree/": { - target: "http://localhost:8181", + target: "http://localhost:18181", secure: false }, "/websocket": { - target: "http://localhost:8181", + target: "http://localhost:18181", + ws: true, + changeOrigin: true, + secure: false + }, + "/apidoc": { + target: "http://localhost:18181", ws: true, changeOrigin: true, secure: false -- cgit 1.2.3-korg