Skip to content
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

allow authenticating using urlencoded passwords #22992

Merged
merged 2 commits into from
Jan 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion build/psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5171,7 +5171,8 @@
<code>$this-&gt;createUserFromBackend($uid, $password, $backend)</code>
<code>$this-&gt;createUserFromBackend($uid, $password, $backend)</code>
</NullableReturnStatement>
<UndefinedInterfaceMethod occurrences="4">
<UndefinedInterfaceMethod occurrences="5">
<code>checkPassword</code>
<code>checkPassword</code>
<code>countUsers</code>
<code>createUser</code>
Expand Down
14 changes: 14 additions & 0 deletions lib/private/User/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,20 @@ public function checkPasswordNoLogging($loginName, $password) {
}
}

// since http basic auth doesn't provide a standard way of handling non ascii password we allow password to be urlencoded
// we only do this decoding after using the plain password fails to maintain compatibility with any password that happens
// to contains urlencoded patterns by "accident".
$password = urldecode($password);

foreach ($this->backends as $backend) {
if ($backend->implementsActions(Backend::CHECK_PASSWORD)) {
$uid = $backend->checkPassword($loginName, $password);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Psalm says:

lib/private/User/Manager.php:241:22:error - UndefinedInterfaceMethod: Method OCP\UserInterface::checkPassword does not exist

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But this is just the same as above. We don't properly export it. But it is there...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we should probably just update the baseline

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

if ($uid !== false) {
return $this->getUserObject($uid, $backend);
}
}
}

return false;
}

Expand Down