From cb35794f02a0f725399450e2d720535d5450bb47 Mon Sep 17 00:00:00 2001 From: MichaIng Date: Fri, 22 Dec 2023 04:10:07 +0100 Subject: [PATCH] fix(dav): fallback realm for HTTP authentication By default, the name of the Nextcloud instance is an empty string, until changed by the admin. This leads to an empty realm sent with the WWW-Authenticate header, while the realm is mandatory for Basic HTTP authentication. Some clients have issues with an empty realm, e.g. Thunderbird cannot store passwords in this case. This commit applies "Nextcloud" as fallback for the realm, in case the name of the Nextcloud instance is not set. Solves: https://help.nextcloud.com/t/thunderbird-dont-save-caldav-password-because-of-missing-httprealm-or-formsubmiturl/93233 Signed-off-by: MichaIng --- apps/dav/lib/Connector/PublicAuth.php | 2 +- apps/dav/lib/Connector/Sabre/Auth.php | 2 +- apps/dav/lib/Connector/Sabre/BearerAuth.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/dav/lib/Connector/PublicAuth.php b/apps/dav/lib/Connector/PublicAuth.php index cc51a249e7570..fb952a8a99518 100644 --- a/apps/dav/lib/Connector/PublicAuth.php +++ b/apps/dav/lib/Connector/PublicAuth.php @@ -61,7 +61,7 @@ public function __construct(IRequest $request, // setup realm $defaults = new \OCP\Defaults(); - $this->realm = $defaults->getName(); + $this->realm = $defaults->getName() ?: 'Nextcloud'; } /** diff --git a/apps/dav/lib/Connector/Sabre/Auth.php b/apps/dav/lib/Connector/Sabre/Auth.php index 69e3946bb1152..d0c309651cd2a 100644 --- a/apps/dav/lib/Connector/Sabre/Auth.php +++ b/apps/dav/lib/Connector/Sabre/Auth.php @@ -76,7 +76,7 @@ public function __construct(ISession $session, // setup realm $defaults = new \OCP\Defaults(); - $this->realm = $defaults->getName(); + $this->realm = $defaults->getName() ?: 'Nextcloud'; } /** diff --git a/apps/dav/lib/Connector/Sabre/BearerAuth.php b/apps/dav/lib/Connector/Sabre/BearerAuth.php index 5a69d07b0026d..b38600bd94431 100644 --- a/apps/dav/lib/Connector/Sabre/BearerAuth.php +++ b/apps/dav/lib/Connector/Sabre/BearerAuth.php @@ -47,7 +47,7 @@ public function __construct(IUserSession $userSession, // setup realm $defaults = new \OCP\Defaults(); - $this->realm = $defaults->getName(); + $this->realm = $defaults->getName() ?: 'Nextcloud'; } private function setupUserFs($userId) {