Skip to content

Commit

Permalink
Merge branch 'master' into geor-header
Browse files Browse the repository at this point in the history
  • Loading branch information
f-necas authored Nov 27, 2023
2 parents 89c94a8 + e15e321 commit 09a2b17
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ backend/.classpath
backend/.project
package-lock.json
.idea/
docker/*.war
16 changes: 14 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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<info@geo-solutions.it>

Expand All @@ -11,8 +18,10 @@ 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"
COPY georchestra-docker-scripts/ /


# Geostore externalization template. Disabled by default
# COPY docker/geostore-datasource-ovr.properties "${CATALINA_BASE}/conf/"
Expand All @@ -23,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
Original file line number Diff line number Diff line change
@@ -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
11 changes: 11 additions & 0 deletions georchestra-docker-scripts/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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 "$@"
43 changes: 35 additions & 8 deletions js/epics/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
};

0 comments on commit 09a2b17

Please sign in to comment.