FedAuth.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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 OCP\Defaults;
  10. use Sabre\DAV\Auth\Backend\AbstractBasic;
  11. use Sabre\HTTP\RequestInterface;
  12. use Sabre\HTTP\ResponseInterface;
  13. class FedAuth extends AbstractBasic {
  14. /**
  15. * FedAuth constructor.
  16. *
  17. * @param DbHandler $db
  18. */
  19. public function __construct(
  20. private DbHandler $db,
  21. ) {
  22. $this->principalPrefix = 'principals/system/';
  23. // setup realm
  24. $defaults = new 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. }