From 5decd0dd657dbe162b0e6489f7d6058ca4e5eab3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Lebleu?= Date: Sun, 10 Jul 2016 18:19:18 +0200 Subject: [PATCH] [enh] Redirect to the SSO dynamically on logging out --- patches/sso-logout.patch | 13 +++++++++++++ scripts/_common.sh | 12 ++++++++++++ scripts/install | 3 +-- scripts/upgrade | 3 +-- 4 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 patches/sso-logout.patch diff --git a/patches/sso-logout.patch b/patches/sso-logout.patch new file mode 100644 index 0000000..0ab2c48 --- /dev/null +++ b/patches/sso-logout.patch @@ -0,0 +1,13 @@ +diff --git a/app/controllers/DisconnectController.php b/app/controllers/DisconnectController.php +index 7af0d4b..74f0c61 100644 +--- a/app/controllers/DisconnectController.php ++++ b/app/controllers/DisconnectController.php +@@ -13,6 +13,7 @@ class DisconnectController extends Base + + Session::dispose(); + +- $this->redirect('login'); ++ $main_domain = exec('cat /etc/yunohost/current_host'); ++ header('Location: https://' . $main_domain . '/yunohost/sso/?action=logout'); + } + } diff --git a/scripts/_common.sh b/scripts/_common.sh index de97d1c..cd6c320 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -11,6 +11,9 @@ HEAD_COMMIT="512523576b03c2c8952305e70681ed31172b9fd2" # Source code destination directory DESTDIR="/var/www/movim" +# App package root directory should be the parent folder +PKGDIR=$(cd ../; pwd) + # # Common helpers # @@ -21,3 +24,12 @@ exec_cmd() { (cd "$DESTDIR" \ && sudo sudo -u movim "$@") } + +# Apply the SSO patch to Movim source code +# usage: apply_sso_patch +apply_sso_patch() { + local patch_path="/tmp/sso-logout.patch" + cp -f "${PKGDIR}/patches/sso-logout.patch" "$patch_path" + exec_cmd git apply "$patch_path" + rm -f "$patch_path" +} diff --git a/scripts/install b/scripts/install index 9352d50..b3f8bcc 100644 --- a/scripts/install +++ b/scripts/install @@ -134,8 +134,7 @@ if [[ "$ssoenabled" = "0" ]]; then exec_cmd php mud.php config --xmppwhitelist="$domain" else ynh_app_setting_set "$app" unprotected_uris "/" - # Next line is to avoid SSO to auto-connect just after disconnect - sudo sed -i "s@redirect('login')@redirect('')@g" $DESTDIR/app/controllers/DisconnectController.php + apply_sso_patch fi # Start Movim diff --git a/scripts/upgrade b/scripts/upgrade index bcc4e7b..4d37b25 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -66,8 +66,7 @@ if [[ "$ssoenabled" =~ ^0|No$ ]]; then exec_cmd php mud.php config --xmppwhitelist=$domain else ynh_app_setting_set "$app" unprotected_uris "/" - # Next line is to avoid SSO to auto-connect just after disconnect - sudo sed -i "s@redirect('login')@redirect('')@g" $DESTDIR/app/controllers/DisconnectController.php + apply_sso_patch fi # Update init scripts