fix: Authorization header can be an empty string#46184
Merged
juliusknorr merged 1 commit intomasterfrom Jul 1, 2024
Merged
Conversation
| ($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
| ($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
Signed-off-by: Julius Härtl <jus@bitgrid.net>
cd3cad0 to
4d6b4b7
Compare
bigcat88
approved these changes
Jun 29, 2024
Member
Author
|
/backport to stable29 |
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
Authorizationheader 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