1
0

FedAuth.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. use Sabre\HTTP\RequestInterface;
  27. use Sabre\HTTP\ResponseInterface;
  28. class FedAuth extends AbstractBasic {
  29. /** @var DbHandler */
  30. private $db;
  31. /**
  32. * FedAuth constructor.
  33. *
  34. * @param DbHandler $db
  35. */
  36. public function __construct(DbHandler $db) {
  37. $this->db = $db;
  38. $this->principalPrefix = 'principals/system/';
  39. // setup realm
  40. $defaults = new \OCP\Defaults();
  41. $this->realm = $defaults->getName();
  42. }
  43. /**
  44. * Validates a username and password
  45. *
  46. * This method should return true or false depending on if login
  47. * succeeded.
  48. *
  49. * @param string $username
  50. * @param string $password
  51. * @return bool
  52. */
  53. protected function validateUserPass($username, $password) {
  54. return $this->db->auth($username, $password);
  55. }
  56. /**
  57. * @inheritdoc
  58. */
  59. public function challenge(RequestInterface $request, ResponseInterface $response) {
  60. }
  61. }