diff options
author | Robin Appelman <icewind@owncloud.com> | 2013-05-28 14:55:42 +0200 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2013-05-28 14:55:42 +0200 |
commit | cc0cf931365d0c515038015bc7792f8500fafcc3 (patch) | |
tree | da17b2d05344140b040fd4c55a3851cdd08154c0 /apps/files_encryption/lib/session.php | |
parent | 9c99048429ff4bf0db742e58931c245d03efb060 (diff) | |
parent | 1d720099c328fe3084e05fe3d2bdd9e49acb8dfe (diff) | |
download | nextcloud-server-cc0cf931365d0c515038015bc7792f8500fafcc3.tar.gz nextcloud-server-cc0cf931365d0c515038015bc7792f8500fafcc3.zip |
merge master into sessionclass
Diffstat (limited to 'apps/files_encryption/lib/session.php')
-rw-r--r-- | apps/files_encryption/lib/session.php | 48 |
1 files changed, 38 insertions, 10 deletions
diff --git a/apps/files_encryption/lib/session.php b/apps/files_encryption/lib/session.php index 30cb7b0e1b3..34913039b0c 100644 --- a/apps/files_encryption/lib/session.php +++ b/apps/files_encryption/lib/session.php @@ -83,17 +83,14 @@ class Session } - if ( \OCP\USER::getUser() === false || - ( isset( $_GET['service'] ) && $_GET['service'] == 'files' && - isset( $_GET['t'] ) ) - ) { + if (\OCA\Encryption\Helper::isPublicAccess()) { // Disable encryption proxy to prevent recursive calls $proxyStatus = \OC_FileProxy::$enabled; \OC_FileProxy::$enabled = false; $encryptedKey = $this->view->file_get_contents( '/owncloud_private_key/' . $publicShareKeyId . '.private.key' ); $privateKey = Crypt::symmetricDecryptFileContent( $encryptedKey, '' ); - $this->setPrivateKey( $privateKey ); + $this->setPublicSharePrivateKey( $privateKey ); \OC_FileProxy::$enabled = $proxyStatus; } @@ -103,6 +100,8 @@ class Session * @brief Sets user private key to session * @param string $privateKey * @return bool + * + * @note this should only be set on login */ public function setPrivateKey( $privateKey ) { @@ -113,24 +112,53 @@ class Session } /** - * @brief Gets user private key from session + * @brief Gets user or public share private key from session * @returns string $privateKey The user's plaintext private key * */ public function getPrivateKey() { - if ( !is_null( \OC::$session->get('privateKey') ) ) { + // return the public share private key if this is a public access + if (\OCA\Encryption\Helper::isPublicAccess()) { + return $this->getPublicSharePrivateKey(); + } else { + if (!is_null( \OC::$session->get('privateKey') )) { + return \OC::$session->get('privateKey'); + } else { + return false; + } + } + } - return \OC::$session->get('privateKey'); + /** + * @brief Sets public user private key to session + * @param string $privateKey + * @return bool + */ + public function setPublicSharePrivateKey($privateKey) { - } else { + \OC::$session->set('publicSharePrivateKey', $privateKey); - return false; + return true; + + } + /** + * @brief Gets public share private key from session + * @returns string $privateKey + * + */ + public function getPublicSharePrivateKey() { + + if (isset($_SESSION['publicSharePrivateKey']) && !empty($_SESSION['publicSharePrivateKey'])) { + return $_SESSION['publicSharePrivateKey']; + } else { + return false; } } + /** * @brief Sets user legacy key to session * @param $legacyKey |