From 7870328957330d3167ed4c066c9bad4bb03b2c59 Mon Sep 17 00:00:00 2001 From: Brahm Prakash Mishra Date: Mon, 7 Aug 2023 22:07:55 +0530 Subject: [PATCH 1/4] Initial working dashboard connection, skipConfirmation not working --- Dockerfile | 13 ++++++++++--- scripts/config-entrypoint.sh | 3 ++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index f44de8ac7..3abc7d836 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,16 +12,23 @@ WORKDIR /usr/local/src/neodash COPY ./package.json /usr/local/src/neodash/package.json RUN yarn install -COPY ./ /usr/local/src/neodash +COPY --chown=101:101 ./ /usr/local/src/neodash RUN yarn run build-minimal # production stage FROM nginxinc/nginx-unprivileged:latest AS neodash -COPY --chown=nginx:nginx --from=build-stage /usr/local/src/neodash/dist /usr/share/nginx/html +COPY --chown=101:101 --from=build-stage /usr/local/src/neodash/dist /usr/share/nginx/html -COPY --chown=nginx:nginx ./conf/default.conf /etc/nginx/conf.d/ +USER root +RUN chown -R 101:101 /usr/share/nginx/html +COPY --chown=101:101 ./conf/default.conf /etc/nginx/conf.d/ +COPY --chown=101:101 ./scripts/config-entrypoint.sh /docker-entrypoint.d/config-entrypoint.sh +COPY --chown=101:101 ./scripts/message-entrypoint.sh /docker-entrypoint.d/message-entrypoint.sh +RUN chmod +x /docker-entrypoint.d/config-entrypoint.sh +RUN chmod +x /docker-entrypoint.d/message-entrypoint.sh +USER 101 EXPOSE 5005 ## Launch webserver as non-root user. diff --git a/scripts/config-entrypoint.sh b/scripts/config-entrypoint.sh index 25374b647..48da8b52a 100644 --- a/scripts/config-entrypoint.sh +++ b/scripts/config-entrypoint.sh @@ -16,4 +16,5 @@ echo " \ \"standaloneDashboardName\": \"${standaloneDashboardName:='My Dashboard'}\", \ \"standaloneDashboardDatabase\": \"${standaloneDashboardDatabase:='neo4j'}\", \ \"standaloneDashboardURL\": \"${standaloneDashboardURL:=}\" \ - }" > /usr/share/nginx/html/config.json + \"skipConfirmation\": "${skipConfirmation:=true}" \ + }" > /usr/share/nginx/html/config.json \ No newline at end of file From 8a94eb691eb0d1096a45f85da6eee15670c4fc30 Mon Sep 17 00:00:00 2001 From: Brahm Prakash Mishra Date: Mon, 7 Aug 2023 22:35:43 +0530 Subject: [PATCH 2/4] Working commit for skipConfirmation in dashboard config json --- src/application/ApplicationActions.ts | 4 +++- src/application/ApplicationReducer.ts | 2 ++ src/application/ApplicationSelectors.ts | 1 + src/application/ApplicationThunks.ts | 6 +++++- src/modal/ConnectionModal.tsx | 8 ++++++++ 5 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/application/ApplicationActions.ts b/src/application/ApplicationActions.ts index 49311d768..9bcdc50d7 100644 --- a/src/application/ApplicationActions.ts +++ b/src/application/ApplicationActions.ts @@ -143,7 +143,8 @@ export const setStandaloneEnabled = ( standaloneDashboardDatabase: string, standaloneDashboardURL: string, standaloneUsername: string, - standalonePassword: string + standalonePassword: string, + skipConfirmation: boolean ) => ({ type: SET_STANDALONE_ENABLED, payload: { @@ -157,6 +158,7 @@ export const setStandaloneEnabled = ( standaloneDashboardURL, standaloneUsername, standalonePassword, + skipConfirmation, }, }); diff --git a/src/application/ApplicationReducer.ts b/src/application/ApplicationReducer.ts index 38f470fe2..2f6e28859 100644 --- a/src/application/ApplicationReducer.ts +++ b/src/application/ApplicationReducer.ts @@ -131,6 +131,7 @@ export const applicationReducer = (state = initialState, action: { type: any; pa standaloneDashboardURL, standaloneUsername, standalonePassword, + skipConfirmation, } = payload; state = update(state, { standalone: standalone, @@ -143,6 +144,7 @@ export const applicationReducer = (state = initialState, action: { type: any; pa standaloneDashboardURL: standaloneDashboardURL, standaloneUsername: standaloneUsername, standalonePassword: standalonePassword, + skipConfirmation: skipConfirmation, }); return state; } diff --git a/src/application/ApplicationSelectors.ts b/src/application/ApplicationSelectors.ts index 263fae4bf..0f127e40c 100644 --- a/src/application/ApplicationSelectors.ts +++ b/src/application/ApplicationSelectors.ts @@ -81,6 +81,7 @@ export const applicationGetStandaloneSettings = (state: any) => { standaloneDashboardURL: state.application.standaloneDashboardURL, standaloneUsername: state.application.standaloneUsername, standalonePassword: state.application.standalonePassword, + skipConfirmation: state.application.skipConfirmation, }; }; diff --git a/src/application/ApplicationThunks.ts b/src/application/ApplicationThunks.ts index bbe18fe5c..a8bf09e28 100644 --- a/src/application/ApplicationThunks.ts +++ b/src/application/ApplicationThunks.ts @@ -350,6 +350,9 @@ export const loadApplicationConfigThunk = () => async (dispatch: any, getState: standaloneDashboardName: 'My Dashboard', standaloneDashboardDatabase: 'dashboards', standaloneDashboardURL: '', + standaloneUsername: 'neo4j', + standalonePassword: 'neo4j', + skipConfirmation: false, }; try { config = await (await fetch('config.json')).json(); @@ -391,7 +394,8 @@ export const loadApplicationConfigThunk = () => async (dispatch: any, getState: config.standaloneDashboardDatabase, config.standaloneDashboardURL, config.standaloneUsername, - config.standalonePassword + config.standalonePassword, + config.skipConfirmation ) ); dispatch(setConnectionModalOpen(false)); diff --git a/src/modal/ConnectionModal.tsx b/src/modal/ConnectionModal.tsx index 1aa068150..b130a4b57 100644 --- a/src/modal/ConnectionModal.tsx +++ b/src/modal/ConnectionModal.tsx @@ -25,6 +25,7 @@ export default function NeoConnectionModal({ const [username, setUsername] = React.useState(connection.username); const [password, setPassword] = React.useState(connection.password); const [database, setDatabase] = React.useState(connection.database); + const [skipConfirmation, setSkipConfirmation] = React.useState(standaloneSettings.skipConfirmation); // Make sure local vars are updated on external connection updates. useEffect(() => { @@ -40,6 +41,13 @@ export default function NeoConnectionModal({ setSsoVisible(ssoSettings.ssoEnabled); }, [JSON.stringify(ssoSettings)]); + useEffect(() => { + if (skipConfirmation && protocol && url && port && database && username && password) { + onConnectionModalClose(); + createConnection(protocol, url, port, database, username, password); + } + }, [skipConfirmation, protocol, url, port, database, username, password]); + const discoveryAPIUrl = ssoSettings && ssoSettings.ssoDiscoveryUrl; return ( From 5468c161c06668360833da48f7663b571634a02d Mon Sep 17 00:00:00 2001 From: Brahm Prakash Mishra Date: Tue, 8 Aug 2023 08:11:16 +0530 Subject: [PATCH 3/4] Working commit with skipConfirmation --- scripts/config-entrypoint.sh | 2 +- src/dashboard/Dashboard.tsx | 2 +- src/modal/ConnectionModal.tsx | 6 +++++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/scripts/config-entrypoint.sh b/scripts/config-entrypoint.sh index 48da8b52a..3576dac55 100644 --- a/scripts/config-entrypoint.sh +++ b/scripts/config-entrypoint.sh @@ -15,6 +15,6 @@ echo " \ \"standalonePassword\": \"${standalonePassword:=}\", \ \"standaloneDashboardName\": \"${standaloneDashboardName:='My Dashboard'}\", \ \"standaloneDashboardDatabase\": \"${standaloneDashboardDatabase:='neo4j'}\", \ - \"standaloneDashboardURL\": \"${standaloneDashboardURL:=}\" \ + \"standaloneDashboardURL\": \"${standaloneDashboardURL:=}\", \ \"skipConfirmation\": "${skipConfirmation:=true}" \ }" > /usr/share/nginx/html/config.json \ No newline at end of file diff --git a/src/dashboard/Dashboard.tsx b/src/dashboard/Dashboard.tsx index cb67636ac..5e673afd4 100644 --- a/src/dashboard/Dashboard.tsx +++ b/src/dashboard/Dashboard.tsx @@ -51,7 +51,7 @@ const Dashboard = ({ pagenumber, connection, applicationSettings, onConnectionUp >
- {applicationSettings.standalonePassword ? ( + {applicationSettings.standalonePassword && applicationSettings.skipConfirmation !== true ? (
Warning: NeoDash is running with a plaintext password in config.json.
diff --git a/src/modal/ConnectionModal.tsx b/src/modal/ConnectionModal.tsx index b130a4b57..885897772 100644 --- a/src/modal/ConnectionModal.tsx +++ b/src/modal/ConnectionModal.tsx @@ -42,11 +42,15 @@ export default function NeoConnectionModal({ }, [JSON.stringify(ssoSettings)]); useEffect(() => { + if (standaloneSettings.skipConfirmation) { + setSkipConfirmation(standaloneSettings.skipConfirmation); + } + if (skipConfirmation && protocol && url && port && database && username && password) { onConnectionModalClose(); createConnection(protocol, url, port, database, username, password); } - }, [skipConfirmation, protocol, url, port, database, username, password]); + }, [standaloneSettings.skipConfirmation, protocol, url, port, database, username, password]); const discoveryAPIUrl = ssoSettings && ssoSettings.ssoDiscoveryUrl; From 887e8f77e3e8dda2ef996aab476a2136f28f2b87 Mon Sep 17 00:00:00 2001 From: Brahm Prakash Mishra Date: Tue, 8 Aug 2023 08:11:48 +0530 Subject: [PATCH 4/4] Changed Dockerfile to copy yarn lock as well --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 3abc7d836..278f64a37 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,10 +9,11 @@ WORKDIR /usr/local/src/neodash #RUN git clone https://github.com/neo4j-labs/neodash.git /usr/local/src/neodash # Copy sources and install/build -COPY ./package.json /usr/local/src/neodash/package.json +COPY ./package.json ./yarn.lock /usr/local/src/neodash/ RUN yarn install COPY --chown=101:101 ./ /usr/local/src/neodash + RUN yarn run build-minimal # production stage