diff options
Diffstat (limited to 'vendor/sabre/dav/lib/DAV')
-rw-r--r-- | vendor/sabre/dav/lib/DAV/Auth/Backend/PDOBasicAuth.php | 114 | ||||
-rw-r--r-- | vendor/sabre/dav/lib/DAV/Auth/Plugin.php | 4 | ||||
-rw-r--r-- | vendor/sabre/dav/lib/DAV/Browser/Plugin.php | 2 | ||||
-rw-r--r-- | vendor/sabre/dav/lib/DAV/Locks/Plugin.php | 4 | ||||
-rw-r--r-- | vendor/sabre/dav/lib/DAV/Server.php | 3 | ||||
-rw-r--r-- | vendor/sabre/dav/lib/DAV/Sync/Plugin.php | 13 | ||||
-rw-r--r-- | vendor/sabre/dav/lib/DAV/Tree.php | 2 | ||||
-rw-r--r-- | vendor/sabre/dav/lib/DAV/Version.php | 2 | ||||
-rw-r--r-- | vendor/sabre/dav/lib/DAV/Xml/Element/Response.php | 22 |
9 files changed, 152 insertions, 14 deletions
diff --git a/vendor/sabre/dav/lib/DAV/Auth/Backend/PDOBasicAuth.php b/vendor/sabre/dav/lib/DAV/Auth/Backend/PDOBasicAuth.php new file mode 100644 index 000000000..39324e4db --- /dev/null +++ b/vendor/sabre/dav/lib/DAV/Auth/Backend/PDOBasicAuth.php @@ -0,0 +1,114 @@ +<?php + +namespace Sabre\DAV\Auth\Backend; + +/** + * This is an authentication backend that uses a database to manage passwords. + * + * @copyright Copyright (C) fruux GmbH (https://fruux.com/) + * @license http://sabre.io/license/ Modified BSD License + */ +class PDOBasicAuth extends AbstractBasic +{ + /** + * Reference to PDO connection. + * + * @var PDO + */ + protected $pdo; + + /** + * PDO table name we'll be using. + * + * @var string + */ + protected $tableName; + + /** + * PDO digest column name we'll be using + * (i.e. digest, password, password_hash). + * + * @var string + */ + protected $digestColumn; + + /** + * PDO uuid(unique user identifier) column name we'll be using + * (i.e. username, email). + * + * @var string + */ + protected $uuidColumn; + + /** + * Digest prefix: + * if the backend you are using for is prefixing + * your password hashes set this option to your prefix to + * cut it off before verfiying. + * + * @var string + */ + protected $digestPrefix; + + /** + * Creates the backend object. + * + * If the filename argument is passed in, it will parse out the specified file fist. + */ + public function __construct(\PDO $pdo, array $options = []) + { + $this->pdo = $pdo; + if (isset($options['tableName'])) { + $this->tableName = $options['tableName']; + } else { + $this->tableName = 'users'; + } + if (isset($options['digestColumn'])) { + $this->digestColumn = $options['digestColumn']; + } else { + $this->digestColumn = 'digest'; + } + if (isset($options['uuidColumn'])) { + $this->uuidColumn = $options['uuidColumn']; + } else { + $this->uuidColumn = 'username'; + } + if (isset($options['digestPrefix'])) { + $this->digestPrefix = $options['digestPrefix']; + } + } + + /** + * Validates a username and password. + * + * This method should return true or false depending on if login + * succeeded. + * + * @param string $username + * @param string $password + * + * @return bool + */ + public function validateUserPass($username, $password) + { + $stmt = $this->pdo->prepare('SELECT '.$this->digestColumn.' FROM '.$this->tableName.' WHERE '.$this->uuidColumn.' = ?'); + $stmt->execute([$username]); + $result = $stmt->fetchAll(); + + if (!count($result)) { + return false; + } else { + $digest = $result[0][$this->digestColumn]; + + if (isset($this->digestPrefix)) { + $digest = substr($digest, strlen($this->digestPrefix)); + } + + if (password_verify($password, $digest)) { + return true; + } + + return false; + } + } +} diff --git a/vendor/sabre/dav/lib/DAV/Auth/Plugin.php b/vendor/sabre/dav/lib/DAV/Auth/Plugin.php index 68adbede5..eb4f27ca6 100644 --- a/vendor/sabre/dav/lib/DAV/Auth/Plugin.php +++ b/vendor/sabre/dav/lib/DAV/Auth/Plugin.php @@ -113,8 +113,6 @@ class Plugin extends ServerPlugin /** * This method is called before any HTTP method and forces users to be authenticated. - * - * @return bool */ public function beforeMethod(RequestInterface $request, ResponseInterface $response) { @@ -204,8 +202,6 @@ class Plugin extends ServerPlugin * This method will for example cause a HTTP Basic backend to set a * WWW-Authorization header, indicating to the client that it should * authenticate. - * - * @return array */ public function challenge(RequestInterface $request, ResponseInterface $response) { diff --git a/vendor/sabre/dav/lib/DAV/Browser/Plugin.php b/vendor/sabre/dav/lib/DAV/Browser/Plugin.php index 2f155d9ea..89495e5db 100644 --- a/vendor/sabre/dav/lib/DAV/Browser/Plugin.php +++ b/vendor/sabre/dav/lib/DAV/Browser/Plugin.php @@ -85,8 +85,6 @@ class Plugin extends DAV\ServerPlugin /** * This method intercepts GET requests that have ?sabreAction=info * appended to the URL. - * - * @return bool */ public function httpGetEarly(RequestInterface $request, ResponseInterface $response) { diff --git a/vendor/sabre/dav/lib/DAV/Locks/Plugin.php b/vendor/sabre/dav/lib/DAV/Locks/Plugin.php index 110bfce06..2443f204c 100644 --- a/vendor/sabre/dav/lib/DAV/Locks/Plugin.php +++ b/vendor/sabre/dav/lib/DAV/Locks/Plugin.php @@ -295,6 +295,10 @@ class Plugin extends DAV\ServerPlugin { $locks = $this->getLocks($path, $includeChildren = true); foreach ($locks as $lock) { + // don't delete a lock on a parent dir + if (0 !== strpos($lock->uri, $path)) { + continue; + } $this->unlockNode($path, $lock); } } diff --git a/vendor/sabre/dav/lib/DAV/Server.php b/vendor/sabre/dav/lib/DAV/Server.php index de663d0c1..1f8300d4a 100644 --- a/vendor/sabre/dav/lib/DAV/Server.php +++ b/vendor/sabre/dav/lib/DAV/Server.php @@ -895,7 +895,7 @@ class Server implements LoggerAwareInterface, EmitterInterface } $propertyNames = $propFind->getRequestedProperties(); - $propFindType = !empty($propertyNames) ? PropFind::NORMAL : PropFind::ALLPROPS; + $propFindType = !$propFind->isAllProps() ? PropFind::NORMAL : PropFind::ALLPROPS; foreach ($this->tree->getChildren($path) as $childNode) { if ('' !== $path) { @@ -1237,6 +1237,7 @@ class Server implements LoggerAwareInterface, EmitterInterface $this->tree->markDirty($parentUri); $this->emit('afterBind', [$uri]); + $this->emit('afterCreateCollection', [$uri]); } /** diff --git a/vendor/sabre/dav/lib/DAV/Sync/Plugin.php b/vendor/sabre/dav/lib/DAV/Sync/Plugin.php index 32106abb3..8609f759e 100644 --- a/vendor/sabre/dav/lib/DAV/Sync/Plugin.php +++ b/vendor/sabre/dav/lib/DAV/Sync/Plugin.php @@ -124,6 +124,10 @@ class Plugin extends DAV\ServerPlugin throw new DAV\Exception\InvalidSyncToken('Invalid or unknown sync token'); } + if (!array_key_exists('result_truncated', $changeInfo)) { + $changeInfo['result_truncated'] = false; + } + // Encoding the response $this->sendSyncCollectionResponse( $changeInfo['syncToken'], @@ -131,7 +135,8 @@ class Plugin extends DAV\ServerPlugin $changeInfo['added'], $changeInfo['modified'], $changeInfo['deleted'], - $report->properties + $report->properties, + $changeInfo['result_truncated'] ); } @@ -141,7 +146,7 @@ class Plugin extends DAV\ServerPlugin * @param string $syncToken * @param string $collectionUrl */ - protected function sendSyncCollectionResponse($syncToken, $collectionUrl, array $added, array $modified, array $deleted, array $properties) + protected function sendSyncCollectionResponse($syncToken, $collectionUrl, array $added, array $modified, array $deleted, array $properties, bool $resultTruncated = false) { $fullPaths = []; @@ -164,6 +169,10 @@ class Plugin extends DAV\ServerPlugin $fullPath = $collectionUrl.'/'.$item; $responses[] = new DAV\Xml\Element\Response($fullPath, [], 404); } + if ($resultTruncated) { + $responses[] = new DAV\Xml\Element\Response($collectionUrl.'/', [], 507); + } + $multiStatus = new DAV\Xml\Response\MultiStatus($responses, self::SYNCTOKEN_PREFIX.$syncToken); $this->server->httpResponse->setStatus(207); diff --git a/vendor/sabre/dav/lib/DAV/Tree.php b/vendor/sabre/dav/lib/DAV/Tree.php index 2417979a6..8215e2c39 100644 --- a/vendor/sabre/dav/lib/DAV/Tree.php +++ b/vendor/sabre/dav/lib/DAV/Tree.php @@ -226,7 +226,7 @@ class Tree // flushing the entire cache $path = trim($path, '/'); foreach ($this->cache as $nodePath => $node) { - if ('' === $path || $nodePath == $path || 0 === strpos($nodePath, $path.'/')) { + if ('' === $path || $nodePath == $path || 0 === strpos((string) $nodePath, $path.'/')) { unset($this->cache[$nodePath]); } } diff --git a/vendor/sabre/dav/lib/DAV/Version.php b/vendor/sabre/dav/lib/DAV/Version.php index b25d6c07a..f8b56bb98 100644 --- a/vendor/sabre/dav/lib/DAV/Version.php +++ b/vendor/sabre/dav/lib/DAV/Version.php @@ -16,5 +16,5 @@ class Version /** * Full version number. */ - public const VERSION = '4.1.5'; + public const VERSION = '4.3.1'; } diff --git a/vendor/sabre/dav/lib/DAV/Xml/Element/Response.php b/vendor/sabre/dav/lib/DAV/Xml/Element/Response.php index 45c161fa4..79f06a09b 100644 --- a/vendor/sabre/dav/lib/DAV/Xml/Element/Response.php +++ b/vendor/sabre/dav/lib/DAV/Xml/Element/Response.php @@ -121,7 +121,7 @@ class Response implements Element foreach ($this->getResponseProperties() as $status => $properties) { // Skipping empty lists - if (!$properties || (!ctype_digit($status) && !is_int($status))) { + if (!$properties || (!is_int($status) && !ctype_digit($status))) { continue; } $empty = false; @@ -186,8 +186,21 @@ class Response implements Element return []; } + + if (!$reader->read()) { + $reader->next(); + + return []; + } + + if (Reader::END_ELEMENT === $reader->nodeType) { + $reader->next(); + + return []; + } + $values = []; - $reader->read(); + do { if (Reader::ELEMENT === $reader->nodeType) { $clark = $reader->getClark(); @@ -199,9 +212,12 @@ class Response implements Element $values[$clark] = $reader->parseCurrentElement()['value']; } } else { - $reader->read(); + if (!$reader->read()) { + break; + } } } while (Reader::END_ELEMENT !== $reader->nodeType); + $reader->read(); return $values; |