FedAuth.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Joas Schilling <coding@schilljs.com>
  6. * @author Thomas Müller <thomas.mueller@tmit.eu>
  7. *
  8. * @license AGPL-3.0
  9. *
  10. * This code is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU Affero General Public License, version 3,
  12. * as published by the Free Software Foundation.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU Affero General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Affero General Public License, version 3,
  20. * along with this program. If not, see <http://www.gnu.org/licenses/>
  21. *
  22. */
  23. namespace OCA\Federation\DAV;
  24. use OCA\Federation\DbHandler;
  25. use Sabre\DAV\Auth\Backend\AbstractBasic;
  26. class FedAuth extends AbstractBasic {
  27. /** @var DbHandler */
  28. private $db;
  29. /**
  30. * FedAuth constructor.
  31. *
  32. * @param DbHandler $db
  33. */
  34. public function __construct(DbHandler $db) {
  35. $this->db = $db;
  36. $this->principalPrefix = 'principals/system/';
  37. // setup realm
  38. $defaults = new \OCP\Defaults();
  39. $this->realm = $defaults->getName();
  40. }
  41. /**
  42. * Validates a username and password
  43. *
  44. * This method should return true or false depending on if login
  45. * succeeded.
  46. *
  47. * @param string $username
  48. * @param string $password
  49. * @return bool
  50. */
  51. protected function validateUserPass($username, $password) {
  52. return $this->db->auth($username, $password);
  53. }
  54. }