From dc133643c957982a514305e696c94b506e880200 Mon Sep 17 00:00:00 2001 From: Maurizio Vitale Date: Wed, 6 Oct 2021 16:18:57 +0100 Subject: [PATCH] Fetch the appName context from window instead of fetching it from env variable (#6631) * Fetch the appName context from window instead of hardcode it * Remove useless file * Get rid of the redirectUri variable Until now the context of the app was created on the backend side and stored on the variable redirectUri. With this fix the context is determined by the FE * remove useless docker variable remove APP_CONFIG_OAUTH2_REDIRECT_LOGIN APP_CONFIG_OAUTH2_REDIRECT_LOGOUT the origin and context will be determined by the FE * Update 30-sed-on-appconfig.sh removing APP_CONFIG_OAUTH2_REDIRECT_LOGOUT and APP_CONFIG_OAUTH2_REDIRECT_LOGIN --- docker/docker-entrypoint.d/30-sed-on-appconfig.sh | 14 -------------- docker/run.sh | 2 -- lib/core/services/alfresco-api.service.ts | 4 ++-- 3 files changed, 2 insertions(+), 18 deletions(-) diff --git a/docker/docker-entrypoint.d/30-sed-on-appconfig.sh b/docker/docker-entrypoint.d/30-sed-on-appconfig.sh index 8fd490da7f0..a4349c4b65a 100755 --- a/docker/docker-entrypoint.d/30-sed-on-appconfig.sh +++ b/docker/docker-entrypoint.d/30-sed-on-appconfig.sh @@ -45,20 +45,6 @@ if [ -n "${APP_CONFIG_OAUTH2_REDIRECT_SILENT_IFRAME_URI}" ]; then -i "${NGINX_ENVSUBST_OUTPUT_DIR}/app.config.json" fi -if [ -n "${APP_CONFIG_OAUTH2_REDIRECT_LOGIN}" ]; then - replace="\/" - encoded=${APP_CONFIG_OAUTH2_REDIRECT_LOGIN//\//$replace} - sed -e "s/\"redirectUri\": \".*\"/\"redirectUri\": \"${encoded}\"/g" \ - -i "${NGINX_ENVSUBST_OUTPUT_DIR}/app.config.json" -fi - -if [ -n "${APP_CONFIG_OAUTH2_REDIRECT_LOGOUT}" ]; then - replace="\/" - encoded=${APP_CONFIG_OAUTH2_REDIRECT_LOGOUT//\//$replace} - sed -e "s/\"redirectUriLogout\": \".*\"/\"redirectUriLogout\": \"${encoded}\"/g" \ - -i "${NGINX_ENVSUBST_OUTPUT_DIR}/app.config.json" -fi - if [[ -n "${APP_CONFIG_BPM_HOST}" ]]; then replace="\/" encoded=${APP_CONFIG_BPM_HOST//\//$replace} diff --git a/docker/run.sh b/docker/run.sh index 4e6fcd4c888..acf4754a318 100755 --- a/docker/run.sh +++ b/docker/run.sh @@ -16,8 +16,6 @@ docker run --rm -it \ --env APP_CONFIG_OAUTH2_IMPLICIT_FLOW=$APP_CONFIG_OAUTH2_IMPLICIT_FLOW \ --env APP_CONFIG_OAUTH2_SILENT_LOGIN=$APP_CONFIG_OAUTH2_SILENT_LOGIN \ --env APP_CONFIG_OAUTH2_REDIRECT_SILENT_IFRAME_URI=$APP_CONFIG_OAUTH2_REDIRECT_SILENT_IFRAME_URI \ - --env APP_CONFIG_OAUTH2_REDIRECT_LOGIN=$APP_CONFIG_OAUTH2_REDIRECT_LOGIN \ - --env APP_CONFIG_OAUTH2_REDIRECT_LOGOUT=$APP_CONFIG_OAUTH2_REDIRECT_LOGOUT \ --env APP_CONFIG_BPM_HOST=$APP_CONFIG_BPM_HOST \ --env APP_CONFIG_ECM_HOST=$APP_CONFIG_ECM_HOST \ --env APP_CONFIG_PROVIDERS=$APP_CONFIG_PROVIDERS \ diff --git a/lib/core/services/alfresco-api.service.ts b/lib/core/services/alfresco-api.service.ts index d0652b230f3..5d5530c7bd4 100644 --- a/lib/core/services/alfresco-api.service.ts +++ b/lib/core/services/alfresco-api.service.ts @@ -65,8 +65,8 @@ export class AlfrescoApiService { protected initAlfrescoApi() { const oauth: OauthConfigModel = Object.assign({}, this.appConfig.get(AppConfigValues.OAUTHCONFIG, null)); if (oauth) { - oauth.redirectUri = window.location.origin + (oauth.redirectUri || '/'); - oauth.redirectUriLogout = window.location.origin + (oauth.redirectUriLogout || '/'); + oauth.redirectUri = window.location.origin + window.location.pathname; + oauth.redirectUriLogout = window.location.origin + window.location.pathname; } const config = new AlfrescoApiConfig({