FedAuth.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
  5. * SPDX-License-Identifier: AGPL-3.0-only
  6. */
  7. namespace OCA\Federation\DAV;
  8. use OCA\Federation\DbHandler;
  9. use Sabre\DAV\Auth\Backend\AbstractBasic;
  10. use Sabre\HTTP\RequestInterface;
  11. use Sabre\HTTP\ResponseInterface;
  12. class FedAuth extends AbstractBasic {
  13. /** @var DbHandler */
  14. private $db;
  15. /**
  16. * FedAuth constructor.
  17. *
  18. * @param DbHandler $db
  19. */
  20. public function __construct(DbHandler $db) {
  21. $this->db = $db;
  22. $this->principalPrefix = 'principals/system/';
  23. // setup realm
  24. $defaults = new \OCP\Defaults();
  25. $this->realm = $defaults->getName();
  26. }
  27. /**
  28. * Validates a username and password
  29. *
  30. * This method should return true or false depending on if login
  31. * succeeded.
  32. *
  33. * @param string $username
  34. * @param string $password
  35. * @return bool
  36. */
  37. protected function validateUserPass($username, $password) {
  38. return $this->db->auth($username, $password);
  39. }
  40. /**
  41. * @inheritdoc
  42. */
  43. public function challenge(RequestInterface $request, ResponseInterface $response) {
  44. }
  45. }