-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Authorization header can be an empty string #46184
Conversation
@@ -185,7 +185,7 @@ | |||
//Fix for broken webdav clients | |||
($this->userSession->isLoggedIn() && is_null($this->session->get(self::DAV_AUTHENTICATED))) || | |||
//Well behaved clients that only send the cookie are allowed | |||
($this->userSession->isLoggedIn() && $this->session->get(self::DAV_AUTHENTICATED) === $this->userSession->getUser()->getUID() && $request->getHeader('Authorization') === null) || | |||
($this->userSession->isLoggedIn() && $this->session->get(self::DAV_AUTHENTICATED) === $this->userSession->getUser()->getUID() && empty($request->getHeader('Authorization'))) || |
Check notice
Code scanning / Psalm
PossiblyNullReference Note
@@ -185,7 +185,7 @@ | |||
//Fix for broken webdav clients | |||
($this->userSession->isLoggedIn() && is_null($this->session->get(self::DAV_AUTHENTICATED))) || | |||
//Well behaved clients that only send the cookie are allowed | |||
($this->userSession->isLoggedIn() && $this->session->get(self::DAV_AUTHENTICATED) === $this->userSession->getUser()->getUID() && $request->getHeader('Authorization') === null) || | |||
($this->userSession->isLoggedIn() && $this->session->get(self::DAV_AUTHENTICATED) === $this->userSession->getUser()->getUID() && empty($request->getHeader('Authorization'))) || |
Check notice
Code scanning / Psalm
RiskyTruthyFalsyComparison Note
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙈
Signed-off-by: Julius Härtl <jus@bitgrid.net>
cd3cad0
to
4d6b4b7
Compare
/backport to stable29 |
On our instance we've noticed that macOS dav clients are actually sending tons of requests. When looking at the network dump of what is happening it turned out that every request is sent twice, one time with a cookie which fails with a 401 and once with basic auth then.
I've been stepping through such a request now and it turned out that our check to see if a
Authorization
header is sent along was not working as it is always filled with an empty string from$_SERVER['HTTP_AUTHORIZATION']
Turns out that once fixing this check, macOS is able to properly reuse the cookies it sends along.
Some screenshots from debugging to easier follow the code that leads to this