From ade52260ea74f27f5c56bd39a1180f3e50009250 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Van=20Der=20Biest?= Date: Tue, 14 Nov 2023 10:44:18 +0100 Subject: [PATCH 1/3] docker - provide unzipped war (#664) * docker - provide unzipped war * take into account edevos review --- Dockerfile | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2ff0486f6..2ee23e042 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,10 @@ +FROM alpine:latest as extractwar +RUN apk --no-cache add unzip +WORKDIR /tmp +COPY docker/MapStore-*.war mapstore.war +RUN unzip mapstore.war -d mapstore + + FROM tomcat:9-jdk11-openjdk MAINTAINER geosolutions @@ -11,8 +18,8 @@ RUN if [ "$TOMCAT_EXTRAS" = false ]; then \ find "${CATALINA_BASE}/webapps/" -delete; \ fi -# Add war files to be deployed -COPY docker/*.war "${CATALINA_BASE}/webapps/mapstore.war" +# Add application from first stage +COPY --from=extractwar /tmp/mapstore "${CATALINA_BASE}/webapps/mapstore" # Geostore externalization template. Disabled by default # COPY docker/geostore-datasource-ovr.properties "${CATALINA_BASE}/conf/" From e5c62a132dfc197dd808003e1281567cfeadeeba Mon Sep 17 00:00:00 2001 From: Florian Necas Date: Mon, 20 Nov 2023 11:09:12 +0100 Subject: [PATCH 2/3] feat: implement custom scripts for mapstore --- .gitignore | 2 ++ Dockerfile | 5 +++++ .../docker-entrypoint.d/100-execute-custom-scripts.sh | 11 +++++++++++ georchestra-docker-scripts/docker-entrypoint.sh | 11 +++++++++++ 4 files changed, 29 insertions(+) create mode 100755 georchestra-docker-scripts/docker-entrypoint.d/100-execute-custom-scripts.sh create mode 100755 georchestra-docker-scripts/docker-entrypoint.sh diff --git a/.gitignore b/.gitignore index a4c109c91..62ad432fa 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,5 @@ coverage/ backend/.classpath backend/.project package-lock.json +.idea/ +docker/*.war \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 2ee23e042..bb7eac9d1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,6 +20,8 @@ RUN if [ "$TOMCAT_EXTRAS" = false ]; then \ # Add application from first stage COPY --from=extractwar /tmp/mapstore "${CATALINA_BASE}/webapps/mapstore" +COPY georchestra-docker-scripts/ / + # Geostore externalization template. Disabled by default # COPY docker/geostore-datasource-ovr.properties "${CATALINA_BASE}/conf/" @@ -30,4 +32,7 @@ ENV JAVA_OPTS="${JAVA_OPTS} ${GEORCHESTRA_DATADIR_OPT}" # Set variable to better handle terminal commands ENV TERM xterm +# Necessary to execute tomcat and custom scripts +ENTRYPOINT ["/docker-entrypoint.sh"] +CMD ["catalina.sh", "run"] EXPOSE 8080 diff --git a/georchestra-docker-scripts/docker-entrypoint.d/100-execute-custom-scripts.sh b/georchestra-docker-scripts/docker-entrypoint.d/100-execute-custom-scripts.sh new file mode 100755 index 000000000..92bbaee50 --- /dev/null +++ b/georchestra-docker-scripts/docker-entrypoint.d/100-execute-custom-scripts.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +# Executing custom scripts located in CUSTOM_SCRIPTS_DIRECTORY if environment variable is set +if [[ -z "${CUSTOM_SCRIPTS_DIRECTORY}" ]]; then + echo "[INFO] No CUSTOM_SCRIPTS_DIRECTORY env variable set" +else + echo "[INFO] CUSTOM_SCRIPTS_DIRECTORY env variable set to ${CUSTOM_SCRIPTS_DIRECTORY}" + # Regex is needed in jetty9 images, but not alpine's ones. + run-parts -v "${CUSTOM_SCRIPTS_DIRECTORY}" --regex='.*' + echo "[INFO] End executing custom scripts" +fi diff --git a/georchestra-docker-scripts/docker-entrypoint.sh b/georchestra-docker-scripts/docker-entrypoint.sh new file mode 100755 index 000000000..874c4ad73 --- /dev/null +++ b/georchestra-docker-scripts/docker-entrypoint.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +DIR=/docker-entrypoint.d + +if [[ -d "$DIR" ]] +then + # Regex is needed to execute all kind of files, including sh files. Warning : --regex not available in alpine images. + /bin/run-parts --verbose "$DIR" --regex='.*' +fi + +exec "$@" From 7d63d83e353937e425fb32c6ae382323f90c2e4c Mon Sep 17 00:00:00 2001 From: Suren Date: Tue, 21 Nov 2023 14:23:35 +0530 Subject: [PATCH 3/3] #638: Redirect to requested resource on login (#665) --- js/epics/login.js | 43 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 8 deletions(-) diff --git a/js/epics/login.js b/js/epics/login.js index f278dace2..e96ee0045 100644 --- a/js/epics/login.js +++ b/js/epics/login.js @@ -7,21 +7,48 @@ */ import {Observable} from "rxjs"; import { LOGIN_REQUIRED } from '@mapstore/actions/security'; +import { LOCATION_CHANGE } from 'connected-react-router'; +import { isLoggedIn } from "@mapstore/selectors/security"; -const goToLoginPage = () => { - window.location.replace('/?login'); +const CAS_REDIRECT_PATH = 'casRedirectPath'; +const goToPage = (path) => { + window.location.replace(path); }; const redirectToLoginPage = (action$) => action$.ofType(LOGIN_REQUIRED) .switchMap(() => { - /* - Note: After login the user is not redirected back to the same resource requested, - as CAS login currently doesn't support that - */ - goToLoginPage(); + window.sessionStorage.setItem(CAS_REDIRECT_PATH, window.location.hash); + /* + Note: After login, the user is not redirected back to the previously requested resource as the CAS skips the hash part. + Hence, the side effect is performed by `casRedirectOnLogin` epic to redirect back to the same resource requested + */ + goToPage('/mapstore/?login'); + return Observable.empty(); + }); + +const casRedirectOnLogin = (action$, state) => + action$.ofType(LOCATION_CHANGE) + .filter(({payload} = {}) => payload?.location?.pathname === '/' && window.sessionStorage.getItem(CAS_REDIRECT_PATH)) + .switchMap(() => { + if (isLoggedIn(state.getState())) { + const redirectPath = window.sessionStorage.getItem(CAS_REDIRECT_PATH); + /* + Once the redirection is performed, redirect path is removed + */ + window.sessionStorage.removeItem(CAS_REDIRECT_PATH); + goToPage(redirectPath); + } else { + /* + Remove redirect path when user manually redirect and/or skips login. + i.e auto redirect is removed in this process to preclude any unforeseen redirections + */ + window.sessionStorage.removeItem(CAS_REDIRECT_PATH); + } + return Observable.empty(); }); export default { - redirectToLoginPage + redirectToLoginPage, + casRedirectOnLogin };