fedauth.php 1.4 KB

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