1<?php
2
3/**
4 * DokuWiki WebDAV Plugin: Auth Backend
5 *
6 * @author  Giuseppe Di Terlizzi <giuseppe.diterlizzi@gmail.com>
7 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
8 * @link    https://dokuwiki.org/plugin:webdav
9 */
10
11namespace dokuwiki\plugin\webdav\core\Backend;
12
13use dokuwiki\plugin\webdav\core\Utils;
14use Sabre\DAV\Auth\Backend\AbstractBasic;
15
16class Auth extends AbstractBasic
17{
18    /**
19     * Validate user credential
20     *
21     * @param string $username
22     * @param string $password
23     *
24     * @return bool
25     */
26    protected function validateUserPass($username, $password)
27    {
28        global $auth;
29
30        $helper = plugin_load('helper', 'webdav');
31
32        $check = $auth->checkPass($username, $password);
33
34        if (!$helper->hasAccess()) {
35            Utils::log('fatal', 'Unauthorized. Check webdav.remoteuser option');
36            return false;
37        }
38
39        return $check;
40    }
41}
42