summaryrefslogtreecommitdiffstats
path: root/lib/private/share
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2015-07-23 14:44:48 +0200
committerThomas Müller <thomas.mueller@tmit.eu>2015-07-23 14:44:48 +0200
commitac08685234249f5045e9f73f49d1cd05c283dbc2 (patch)
tree2b685356ca893f5126b28e54824b8fa4946aa7d3 /lib/private/share
parent9ccf94ca06806ad5312d3ac06b8b25388f3ec5f4 (diff)
downloadnextcloud-server-ac08685234249f5045e9f73f49d1cd05c283dbc2.tar.gz
nextcloud-server-ac08685234249f5045e9f73f49d1cd05c283dbc2.zip
Use a hook to integrate sharing password verification
Diffstat (limited to 'lib/private/share')
-rw-r--r--lib/private/share/share.php22
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/private/share/share.php b/lib/private/share/share.php
index 41b60ecc638..ab42c0daab4 100644
--- a/lib/private/share/share.php
+++ b/lib/private/share/share.php
@@ -737,6 +737,7 @@ class Share extends Constants {
// Generate hash of password - same method as user passwords
if (!empty($shareWith)) {
+ self::verifyPassword($shareWith);
$shareWith = \OC::$server->getHasher()->hash($shareWith);
} else {
// reuse the already set password, but only if we change permissions
@@ -1252,6 +1253,8 @@ class Share extends Constants {
throw new \Exception('Cannot remove password');
}
+ self::verifyPassword($password);
+
$qb = $connection->getQueryBuilder();
$qb->update('*PREFIX*share')
->set('share_with', $qb->createParameter('pass'))
@@ -2604,4 +2607,23 @@ class Share extends Constants {
$result = \OC::$server->getDatabaseConnection()->executeQuery($query, [$id]);
return $result->fetchAll();
}
+
+ /**
+ * @param string $password
+ * @throws \Exception
+ */
+ private static function verifyPassword($password) {
+
+ $accepted = true;
+ $message = '';
+ \OCP\Util::emitHook('\OC\Share', 'verifyPassword', [
+ 'password' => $password,
+ 'accepted' => &$accepted,
+ 'message' => &$message
+ ]);
+
+ if (!$accepted) {
+ throw new \Exception($message);
+ }
+ }
}