From daa381103a5df6415eddf5baf9ed1cfae400f618 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Fri, 20 Jul 2018 15:06:49 +0200 Subject: [PATCH] Fix certificat issue --- check_process | 6 +- conf/settings.php | 2 +- manifest.json | 8 --- scripts/install | 8 --- scripts/upgrade | 13 ----- sources/patches/add-http-auth_new_try.patch | 35 +++++++++++ .../patches/app-00-add-http-auth.patch.old | 58 +++++++++++++++++++ 7 files changed, 96 insertions(+), 34 deletions(-) create mode 100644 sources/patches/add-http-auth_new_try.patch create mode 100644 sources/patches/app-00-add-http-auth.patch.old diff --git a/check_process b/check_process index 6efab9e..1c21f46 100644 --- a/check_process +++ b/check_process @@ -4,18 +4,16 @@ domain="domain.tld" (DOMAIN) path="/path" (PATH) language="fr" - disablecacheck=1 ; pre-install sudo yunohost app fetchlist - sudo yunohost domain add --verbose baikaldomain.tld --admin-password $PASSWORD + sudo yunohost domain add baikaldomain.tld --admin-password $PASSWORD sudo yunohost app install baikal -a "domain=baikaldomain.tld&path=/baikal&password=admin" ; Checks pkg_linter=1 setup_sub_dir=1 setup_root=0 setup_nourl=0 -# Private test only should be fixed in package check before. -# setup_private=1 + setup_private=1 setup_public=0 upgrade=1 backup_restore=1 diff --git a/conf/settings.php b/conf/settings.php index ac70cb2..0dbbe83 100644 --- a/conf/settings.php +++ b/conf/settings.php @@ -40,7 +40,7 @@ $app['caldav.baseurl'] = '{CALDAV_BASEURL}'; $app['caldav.authmethod'] = 'basic'; // Do not verify SSL certificate, it is self signed -$app['caldav.certificate.verify'] = __CACHECK__; +$app['caldav.certificate.verify'] = false; // Whether to show public CalDAV urls $app['caldav.publicurls'] = true; diff --git a/manifest.json b/manifest.json index 814e55b..2c57fe1 100644 --- a/manifest.json +++ b/manifest.json @@ -53,14 +53,6 @@ "de", "en", "es", "fr", "it", "nl" ], "default": "en" - }, - { - "name": "disablecacheck", - "ask": { - "en": "Disable certificate checks? (if not using a valid certificate)" - }, - "type": "boolean", - "default": false } ] } diff --git a/scripts/install b/scripts/install index 829758c..2a74f87 100644 --- a/scripts/install +++ b/scripts/install @@ -23,7 +23,6 @@ ynh_abort_if_errors domain=$YNH_APP_ARG_DOMAIN path_url=$YNH_APP_ARG_PATH language=$YNH_APP_ARG_LANGUAGE -disablecacheck=$YNH_APP_ARG_DISABLECACHECK # Set and store language language=${LANGUAGES[$language]} @@ -75,7 +74,6 @@ fi ynh_app_setting_set "$app" language "$language" ynh_app_setting_set "$app" path "$path_url" ynh_app_setting_set "$app" domain "$domain" -ynh_app_setting_set "$app" disablecacheck "$disablecacheck" ynh_app_setting_set "$app" final_path "$final_path" #================================================= @@ -151,12 +149,6 @@ ynh_replace_string "{LANGUAGE}" "${language}" "$conf_path" ynh_replace_string "{CALDAV_BASEURL}" "${caldav_url}${caldav_baseurl}" "$conf_path" ynh_replace_string "{CALDAV_DOMAIN}" "${caldav_domain}" "$conf_path" -if [ "$disablecacheck" -eq 0 ]; then - ynh_replace_string "__CACHECK__" "true" "$conf_path" -else - ynh_replace_string "__CACHECK__" "false" "$conf_path" -fi - #================================================= # STORE THE CHECKSUM OF THE CONFIG FILE #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index b8f016e..69213ca 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -24,7 +24,6 @@ path_url=$(ynh_app_setting_get "$app" path) dbpass=$(ynh_app_setting_get "$app" mysqlpwd) encryptkey=$(ynh_app_setting_get "$app" encryptkey) language=$(ynh_app_setting_get "$app" language) -disablecacheck=$(ynh_app_setting_get "$app" disablecacheck) LOGDIR=/var/log/$app @@ -59,12 +58,6 @@ if [ -z "$db_name" ]; then ynh_app_setting_set "$app" db_name "$db_name" fi -# If disablecacheck doesn't exist, create it -if [ -z "$disablecacheck" ]; then - disablecacheck=0 - ynh_app_setting_set "$app" disablecacheck "$disablecacheck" -fi - # If final_path doesn't exist, create it if [ -z "$final_path" ]; then final_path=/var/www/$app @@ -170,12 +163,6 @@ ynh_replace_string "{LANGUAGE}" "${language}" "$conf_path" ynh_replace_string "{CALDAV_BASEURL}" "${caldav_url}${caldav_baseurl}" "$conf_path" ynh_replace_string "{CALDAV_DOMAIN}" "${caldav_domain}" "$conf_path" -if [ "$disablecacheck" -eq 0 ]; then - ynh_replace_string "__CACHECK__" "true" "$conf_path" -else - ynh_replace_string "__CACHECK__" "false" "$conf_path" -fi - #================================================= # STORE THE CHECKSUM OF THE CONFIG FILE #================================================= diff --git a/sources/patches/add-http-auth_new_try.patch b/sources/patches/add-http-auth_new_try.patch new file mode 100644 index 0000000..9f52b39 --- /dev/null +++ b/sources/patches/add-http-auth_new_try.patch @@ -0,0 +1,35 @@ +--- a/web/src/Controller/Authentication.php ++++ b/web/src/Controller/Authentication.php +@@ -83,7 +83,7 @@ + * @param Application $app + * @return bool false if authentication failed, true otherwise + */ +- protected function processLogin($user, $password, Application $app) ++ public function processLogin($user, $password, Application $app) + { + $app['http.client']->setAuthentication($user, $password, $app['caldav.authmethod']); + +--- a/web/app/controllers.php ++++ b/web/app/controllers.php +@@ -7,6 +7,7 @@ + use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; + use Silex\Application; + ++use AgenDAV\Controller\Authentication; + use AgenDAV\DateHelper; + + // Authentication +@@ -68,6 +69,13 @@ + return; + } + ++ if ($request->headers->get('authorization') != null) { ++ $authController = new Authentication(); ++ if ($authController->processLogin($request->headers->get('PHP_AUTH_USER'), $request->headers->get('PHP_AUTH_PW'), $app)) { ++ return; ++ } ++ } ++ + if ($request->isXmlHttpRequest()) { + return new JsonResponse([], 401); + } else { diff --git a/sources/patches/app-00-add-http-auth.patch.old b/sources/patches/app-00-add-http-auth.patch.old new file mode 100644 index 0000000..20a6304 --- /dev/null +++ b/sources/patches/app-00-add-http-auth.patch.old @@ -0,0 +1,58 @@ +--- a/web/app/controllers.php ++++ b/web/app/controllers.php +@@ -58,14 +58,20 @@ + // processing the request + if ($app['session']->has('username')) { + $username = $app['session']->get('username'); +- $preferences = $app['preferences.repository']->userPreferences($username); +- $app['user.preferences'] = $preferences; +- $app['user.timezone'] = $preferences->get('timezone'); ++ // Clear user session if HTTP authentication changed ++ if (isset($_SERVER['PHP_AUTH_USER']) ++ && $username != $_SERVER['PHP_AUTH_USER']) { ++ $app['session']->clear(); ++ } else { ++ $preferences = $app['preferences.repository']->userPreferences($username); ++ $app['user.preferences'] = $preferences; ++ $app['user.timezone'] = $preferences->get('timezone'); + +- // Set application language +- $request->setLocale($preferences->get('language')); +- $app['translator']->setLocale($preferences->get('language')); +- return; ++ // Set application language ++ $request->setLocale($preferences->get('language')); ++ $app['translator']->setLocale($preferences->get('language')); ++ return; ++ } + } + + if ($request->isXmlHttpRequest()) { +--- a/web/src/Controller/Authentication.php ++++ b/web/src/Controller/Authentication.php +@@ -34,7 +34,7 @@ + $success = false; + $template_vars = []; + +- if ($request->isMethod('POST')) { ++ if ($request->isMethod('POST') || isset($_SERVER['PHP_AUTH_USER'])) { + $user = $request->request->get('user'); + $password = $request->request->get('password'); + +@@ -93,8 +93,14 @@ + return false; + } + +- $app['session']->set('username', $user); +- $app['session']->set('password', $password); ++ if (isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW'])) { ++ $user = $_SERVER['PHP_AUTH_USER']; ++ $password = $_SERVER['PHP_AUTH_PW']; ++ } else { ++ $app['session']->set('username', $user); ++ $app['session']->set('password', $password); ++ } ++ + $principal_url = $caldav_client->getCurrentUserPrincipal(); + + $principals_repository = $app['principals.repository'];