From b392321e732ad5f9474d691c235bd9bdc68cedd9 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 19 Oct 2021 13:03:23 +0200 Subject: [PATCH] Fix basic auth for OAuth token endpoint Don't try to login when a client is trying to get a OAuth token. OAuth needs to support basic auth too, so the login is not valid inside Nextcloud and the Login exception would ruin it. Signed-off-by: Joas Schilling --- lib/base.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/base.php b/lib/base.php index 473a3419cb143..2e6e2a65d80fc 100644 --- a/lib/base.php +++ b/lib/base.php @@ -987,7 +987,13 @@ public static function handleRequest() { } else { // For guests: Load only filesystem and logging OC_App::loadApps(['filesystem', 'logging']); - self::handleLogin($request); + + // Don't try to login when a client is trying to get a OAuth token. + // OAuth needs to support basic auth too, so the login is not valid + // inside Nextcloud and the Login exception would ruin it. + if ($request->getRawPathInfo() !== '/apps/oauth2/api/v1/token') { + self::handleLogin($request); + } } }