From 733d5768312007d81e5d43512ed00ab39136f70b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Lebleu?= Date: Mon, 4 Apr 2016 22:00:04 +0200 Subject: [PATCH] [enh] Patch ownCloud to config the logout URL and set it to SSOwat one --- README.md | 2 -- patches/00-add-logout_url-conf.patch | 15 +++++++++++++++ scripts/_common.sh | 6 ++++++ scripts/install | 10 ++++++++++ scripts/upgrade | 11 +++++++++++ 5 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 patches/00-add-logout_url-conf.patch diff --git a/README.md b/README.md index 7a4ebcd..f120286 100644 --- a/README.md +++ b/README.md @@ -29,8 +29,6 @@ or from the Web administration: ## TODO * Test the upgrade from the current official package - * Develop an app to integrate SSOwat logout - see - [here](https://doc.owncloud.org/server/9.0/developer_manual/app/hooks.html#session) * Update the external storage plugin configuration - see [here](https://doc.owncloud.org/server/9.0/admin_manual/configuration_server/occ_command.html#files-external-label) * Rescan filesystem at upgrade and restoration - see diff --git a/patches/00-add-logout_url-conf.patch b/patches/00-add-logout_url-conf.patch new file mode 100644 index 0000000..54388e2 --- /dev/null +++ b/patches/00-add-logout_url-conf.patch @@ -0,0 +1,15 @@ +--- a/lib/base.php 2016-04-04 21:26:47.281448433 +0200 ++++ b/lib/base.php 2016-04-04 21:27:16.034283534 +0200 +@@ -920,8 +920,10 @@ + \OC::$server->getConfig()->deleteUserValue(OC_User::getUser(), 'login_token', $_COOKIE['oc_token']); + } + OC_User::logout(); +- // redirect to webroot and add slash if webroot is empty +- header("Location: " . \OC::$server->getURLGenerator()->getAbsoluteURL('/')); ++ // Use system config or redirect to webroot and add slash if webroot is empty ++ $redirect_url = $systemConfig->getValue('logout_url', ++ \OC::$server->getURLGenerator()->getAbsoluteURL('/')); ++ header("Location: " . $redirect_url); + } else { + // Redirect to default application + OC_Util::redirectToDefaultPage(); diff --git a/scripts/_common.sh b/scripts/_common.sh index 48562fa..9443390 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -46,6 +46,12 @@ extract_owncloud() { exec_as "$AS_USER" tar xjf "$oc_tarball" -C "$DESTDIR" --strip-components 1 \ || die "Unable to extract ownCloud tarball" rm -f "$oc_tarball" + + # apply patches + (cd "$DESTDIR" \ + && for p in ${PKGDIR}/patches/*.patch; do \ + exec_as "$AS_USER" patch -p1 < $p; done) \ + || die "Unable to apply patches to ownCloud" } # Execute a command as another user diff --git a/scripts/install b/scripts/install index f634d0d..e8da711 100755 --- a/scripts/install +++ b/scripts/install @@ -111,6 +111,16 @@ sudo rm -f "$oc_conf" _exec_occ ldap:test-config \'\' \ || die "An error occured during LDAP configuration" +# Add dynamic logout URL to the config +_exec_occ config:system:get logout_url >/dev/null 2>&1 \ + || sudo su -c "echo \" +//-YunoHost- +// set logout_url according to main domain +\\\$main_domain = exec('cat /etc/yunohost/current_host'); +\\\$CONFIG['logout_url'] = 'https://'.\\\$main_domain.'/yunohost/sso/?action=logout'; +//-YunoHost- +\" >> ${DESTDIR}/config/config.php" -- $app + # Set the user as admin and delete admin user ynh_mysql_connect_as $dbuser $dbpass $dbname \ <<< "INSERT INTO oc_group_user VALUES ('admin','$admin');" diff --git a/scripts/upgrade b/scripts/upgrade index 373557e..3f407dc 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -103,6 +103,17 @@ _exec_occ app:enable user_ldap _exec_occ config:import "$oc_conf" sudo rm -f "$oc_conf" +# Add dynamic logout URL to the config +# TODO: if changes are made to this section, replace it with new one. +_exec_occ config:system:get logout_url >/dev/null 2>&1 \ + || sudo su -c "echo \" +//-YunoHost- +// set logout_url according to main domain +\\\$main_domain = exec('cat /etc/yunohost/current_host'); +\\\$CONFIG['logout_url'] = 'https://'.\\\$main_domain.'/yunohost/sso/?action=logout'; +//-YunoHost- +\" >> ${DESTDIR}/config/config.php" -- $app + # Iterate over users to extend their home folder permissions - for the external # storage plugin usage - and create relevant ownCloud directories for u in $(ynh_user_list); do