Skip to content
35 changes: 35 additions & 0 deletions lib/private/Files/Storage/DAV.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,41 @@
use Sabre\HTTP\ClientException;
use Sabre\HTTP\ClientHttpException;
use Sabre\HTTP\RequestInterface;
Copy link
Author

@enriquepablo enriquepablo Dec 17, 2025

Choose a reason for hiding this comment

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

Mistake breaking up the code into commits, the missing open-comment is added in a later commit:

bcf7ea1#diff-53ee4c908f9ae3a27e45d03c57ac5ed83c5916d7260561a03f279880671f6155R42

Sorry about this, I'll re-arrange a fixed pr asap.

* Class BearerAuthAwareSabreClient
*
* This is an extension of the Sabre HTTP Client
* to provide it with the ability to make bearer authn requests.
*
* @package OC\Files\Storage
*/
class BearerAuthAwareSabreClient extends Client
{
/**
* Bearer authentication.
*/
const AUTH_BEARER = 8;

/**
* Constructor.
*
* See Sabre\DAV\Client
*
*/
public function __construct(array $settings)
{
parent::__construct($settings);

if (isset($settings['userName']) && isset($settings['authType']) && ($settings['authType'] & self::AUTH_BEARER)) {
$userName = $settings['userName'];

$curlType = $this->curlSettings[CURLOPT_HTTPAUTH];
$curlType |= CURLAUTH_BEARER;

$this->addCurlSetting(CURLOPT_HTTPAUTH, $curlType);
$this->addCurlSetting(CURLOPT_XOAUTH2_BEARER, $userName);
}
}
}

/**
* Class DAV
Expand Down