mirror of
https://github.com/YunoHost-Apps/agendav_ynh.git
synced 2024-09-03 20:36:12 +02:00
Fix certificat issue
This commit is contained in:
parent
d5a94d9a85
commit
daa381103a
7 changed files with 96 additions and 34 deletions
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -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
|
||||
#=================================================
|
||||
|
|
|
@ -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
|
||||
#=================================================
|
||||
|
|
35
sources/patches/add-http-auth_new_try.patch
Normal file
35
sources/patches/add-http-auth_new_try.patch
Normal file
|
@ -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 {
|
58
sources/patches/app-00-add-http-auth.patch.old
Normal file
58
sources/patches/app-00-add-http-auth.patch.old
Normal file
|
@ -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'];
|
Loading…
Add table
Reference in a new issue