Skip to content

fix: Use PHP_AUTH_PW for strict password confirmation - #62477

Merged
SystemKeeper merged 2 commits into
masterfrom
fix/62362/password-confirmation-php-auth-pw
Jul 29, 2026
Merged

fix: Use PHP_AUTH_PW for strict password confirmation#62477
SystemKeeper merged 2 commits into
masterfrom
fix/62362/password-confirmation-php-auth-pw

Conversation

@SystemKeeper

@SystemKeeper SystemKeeper commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Summary

We already make sure that AUTHORIZATION headers are copied to PHP_AUTH_USER and PHP_AUTH_PW, so these should work in all cases.

server/lib/OC.php

Lines 1297 to 1318 in 3541356

protected static function handleAuthHeaders(): void {
//copy http auth headers for apache+php-fcgid work around
if (isset($_SERVER['HTTP_XAUTHORIZATION']) && !isset($_SERVER['HTTP_AUTHORIZATION'])) {
$_SERVER['HTTP_AUTHORIZATION'] = $_SERVER['HTTP_XAUTHORIZATION'];
}
// Extract PHP_AUTH_USER/PHP_AUTH_PW from other headers if necessary.
$vars = [
'HTTP_AUTHORIZATION', // apache+php-cgi work around
'REDIRECT_HTTP_AUTHORIZATION', // apache+php-cgi alternative
];
foreach ($vars as $var) {
if (isset($_SERVER[$var]) && is_string($_SERVER[$var]) && preg_match('/Basic\s+(.*)$/i', $_SERVER[$var], $matches)) {
$credentials = explode(':', base64_decode($matches[1]), 2);
if (count($credentials) === 2) {
$_SERVER['PHP_AUTH_USER'] = $credentials[0];
$_SERVER['PHP_AUTH_PW'] = $credentials[1];
break;
}
}
}
}

Please check if there's any reason to access the raw authorization header in that method, in that case we could use the PHP_AUTH_* ones as fallback.

Checklist

AI (if applicable)

  • The content of this PR was partly or fully generated using AI

@SystemKeeper SystemKeeper self-assigned this Jul 24, 2026
@SystemKeeper
SystemKeeper force-pushed the fix/62362/password-confirmation-php-auth-pw branch from 38fb22e to eebb3a2 Compare July 24, 2026 11:54
@SystemKeeper SystemKeeper changed the title Fix/62362/password confirmation php auth pw fix: Use PHP_AUTH_PW for strict password confirmation Jul 24, 2026
@SystemKeeper SystemKeeper added the 3. to review Waiting for reviews label Jul 24, 2026
@SystemKeeper
SystemKeeper marked this pull request as ready for review July 24, 2026 12:37
@SystemKeeper
SystemKeeper requested a review from a team as a code owner July 24, 2026 12:37
@SystemKeeper
SystemKeeper requested review from Altahrim, leftybournes, provokateurin and salmart-dev and removed request for a team July 24, 2026 12:37
@SystemKeeper

Copy link
Copy Markdown
Contributor Author

/backport! to stable34

Comment on lines +229 to +236
$thrown = false;
try {
$this->middleware->beforeController($this->controller, __FUNCTION__);
} catch (NotConfirmedException) {
$thrown = true;
}

$this->assertSame(false, $thrown);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can be simplified to just call the method without a catch and assertion.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I was just following the schema that is used in the file already.

@susnux susnux left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

makes sense!

Signed-off-by: Marcel Müller <marcel-mueller@gmx.de>
Signed-off-by: Marcel Müller <marcel-mueller@gmx.de>
@SystemKeeper
SystemKeeper force-pushed the fix/62362/password-confirmation-php-auth-pw branch from eebb3a2 to 07e123e Compare July 29, 2026 16:44
@SystemKeeper
SystemKeeper merged commit c6d5152 into master Jul 29, 2026
253 of 262 checks passed
@SystemKeeper
SystemKeeper deleted the fix/62362/password-confirmation-php-auth-pw branch July 29, 2026 17:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review Waiting for reviews 34-feedback bug feature: authentication php Pull requests that update Php code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Creating and deleting App Tokens runs into error

3 participants