2015-12-03 16:22:18 +01:00
|
|
|
<?php
|
2024-05-28 16:42:42 +02:00
|
|
|
|
2015-12-03 16:22:18 +01:00
|
|
|
/**
|
2024-05-28 16:42:42 +02:00
|
|
|
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
2015-12-03 16:22:18 +01:00
|
|
|
*/
|
2015-12-04 12:11:07 +01:00
|
|
|
namespace OCA\Federation\DAV;
|
2015-12-03 16:22:18 +01:00
|
|
|
|
|
|
|
use OCA\Federation\DbHandler;
|
2024-10-10 12:40:31 +02:00
|
|
|
use OCP\Defaults;
|
2015-12-03 16:22:18 +01:00
|
|
|
use Sabre\DAV\Auth\Backend\AbstractBasic;
|
2016-10-20 12:52:24 +02:00
|
|
|
use Sabre\HTTP\RequestInterface;
|
|
|
|
use Sabre\HTTP\ResponseInterface;
|
2015-12-03 16:22:18 +01:00
|
|
|
|
|
|
|
class FedAuth extends AbstractBasic {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* FedAuth constructor.
|
|
|
|
*
|
2015-12-07 15:28:06 +01:00
|
|
|
* @param DbHandler $db
|
2015-12-03 16:22:18 +01:00
|
|
|
*/
|
2024-10-18 12:04:22 +02:00
|
|
|
public function __construct(
|
|
|
|
private DbHandler $db,
|
|
|
|
) {
|
2015-12-03 16:22:18 +01:00
|
|
|
$this->principalPrefix = 'principals/system/';
|
2016-06-09 13:53:32 +02:00
|
|
|
|
|
|
|
// setup realm
|
2024-10-10 12:40:31 +02:00
|
|
|
$defaults = new Defaults();
|
2016-06-09 13:53:32 +02:00
|
|
|
$this->realm = $defaults->getName();
|
2015-12-03 16:22:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Validates a username and password
|
|
|
|
*
|
|
|
|
* This method should return true or false depending on if login
|
|
|
|
* succeeded.
|
|
|
|
*
|
|
|
|
* @param string $username
|
|
|
|
* @param string $password
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
protected function validateUserPass($username, $password) {
|
2015-12-07 15:28:06 +01:00
|
|
|
return $this->db->auth($username, $password);
|
2015-12-03 16:22:18 +01:00
|
|
|
}
|
2016-10-20 12:52:24 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
2017-08-02 14:34:51 +02:00
|
|
|
public function challenge(RequestInterface $request, ResponseInterface $response) {
|
2016-10-20 12:52:24 +02:00
|
|
|
}
|
2015-12-03 16:22:18 +01:00
|
|
|
}
|