Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Owncloud 10.2.1 incompatibility #40

Open
wants to merge 37 commits into
base: feature/ZD-132-nextcloud-13-compatibility
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
419db60
Merge pull request #56 in ZX/zimbra-drive from feature/ZD-132-nextclo…
ZxUgoPadoan Mar 1, 2018
64d144b
Updated *Cloud App version to 0.8.19
ZxUgoPadoan Mar 15, 2018
773035c
App, fixed Zimbra Drive's extension connectivity test executed in a s…
ZxUgoPadoan Mar 19, 2018
6a06d18
Merge pull request #57 in ZX/zimbra-drive from fix-zimbradriveextensi…
Mar 23, 2018
1887956
Updated README.md
ZxUgoPadoan May 4, 2018
6aa46a8
Merge pull request #58 in ZX/zimbra-drive from issues-section-update-…
May 11, 2018
7ad8753
ZX-4766, fixed login with postgresql
ZxUgoPadoan Jul 30, 2018
b3588dc
* support for shared and mounted folders
adrb Oct 30, 2018
de082b4
Merge remote-tracking branch 'adrb/path_names_for_group_and_shared_fi…
ZxUgoPadoan Nov 9, 2018
a79fef6
Added some check in order to manage errors caused by lack of persemis…
ZxUgoPadoan Nov 12, 2018
2e1c48b
Merge pull request #59 in ZX/zimbra-drive from enable-shared-files to…
Nov 12, 2018
1be5b5e
Added retro compatibility to the Nextcloud / ownCloud app.
ZxUgoPadoan Nov 14, 2018
795db78
Fixed the download of a file
ZxUgoPadoan Nov 14, 2018
dc2bf99
Fixed the app searchRequest
ZxUgoPadoan Nov 15, 2018
cba1dd4
Merge pull request #60 in ZX/zimbra-drive from ZX-5530-enable-shared-…
Nov 15, 2018
47447b2
Updated the version of the extension to 2.0.3
ZxUgoPadoan Nov 15, 2018
b06a887
Updated the version of the zimlet to 2.0.3
ZxUgoPadoan Nov 15, 2018
0ad6bf1
Changed the name of the tab of the zimlet to "Open Drive"
ZxUgoPadoan Nov 15, 2018
04a1d72
Renamed zimlet's tab to "Open Drive"
ZxUgoPadoan Nov 26, 2018
6a34b57
Lifecycle statement in Readme
ZxCine Jan 24, 2019
9c9aef9
Merge remote-tracking branch 'github/master'
Feb 8, 2019
bdc9666
Adding SET_ZIMBRA_GROUP_TO_USERS setting (#29)
sanchezfauste Feb 8, 2019
bce1497
Add first Jenkinsfile
Polpetta Feb 27, 2019
0d3ee2f
Add nvm integration
Polpetta Feb 28, 2019
d41dcff
Add Jenkins email notifications
Polpetta Mar 19, 2019
1ec1f3f
Add log rotation option - the last 50 build logs are kept
Polpetta Mar 26, 2019
e5c6159
ZX-6008 Sanitized previously broken strings which allowed code execution
Mar 27, 2019
4784744
Merge pull request #62 in ZX/zimbra-drive from bugfix/ZX-6008-driveop…
Mar 28, 2019
4273aa4
Indicate support for Nextcloud 14 and 15 (#38)
chbusold Mar 28, 2019
adcf8ac
Indicate support for Nextcloud 14 and 15 (#38)
chbusold Mar 28, 2019
e16a2d6
Merge branch 'master' of github.com:ZeXtras/zimbra-drive
Mar 28, 2019
3c854d2
Updated zimlet and Nextcloud app versions.
Mar 28, 2019
eaf6107
Merge pull request #61 in ZX/zimbra-drive from jenkins_integration to…
davide-baldo Mar 28, 2019
8bf2447
Build
ZeXtrasJay Apr 15, 2019
dae4f98
Build - Fixed
ZeXtrasJay Apr 15, 2019
f330259
Merge remote-tracking branch 'origin/master' into rename-tab
Apr 17, 2019
dd9d556
Merged in rename-tab (pull request #1)
Apr 17, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
pipeline {
agent {
node {
label 'nodejs-agent-v1'
}
}
options {
buildDiscarder(logRotator(numToKeepStr: '50'))
}
stages {
stage('Node version') {
steps {
sh '. /usr/bin/load_nvm && nvm use 6'
}
}
stage('Make') {
steps {
sh '. /usr/bin/load_nvm && make clean all'
archiveArtifacts artifacts: "dist/zimbra_drive.tgz", fingerprint: true
archiveArtifacts artifacts: "dist/zimbradrive.tar.gz", fingerprint: true
archiveArtifacts artifacts: "dist/zimbra_drive.md5", fingerprint: true
}
}
}
post {
always {
script {
GIT_COMMIT_EMAIL = sh (
script: 'git --no-pager show -s --format=\'%ae\'',
returnStdout: true
).trim()
}
emailext attachLog: true, body: '$DEFAULT_CONTENT', recipientProviders: [requestor()], subject: '$DEFAULT_SUBJECT', to: "${GIT_COMMIT_EMAIL}"
}
}
}
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
Zimbra Drive
Open Drive
============

Open Drive is not not a fully fledged Zextras product under active support and development, but a contribution provided to the Zimbra Community "as is".

Anyone is free to download it and to clone the repository to apply any change complying with the project's licensing but there is no official commitment on updates, on the inclusion of features and/or the approval of pull requests.

---


Zimbra and Nextcloud / ownCloud integration.

Features:
Expand All @@ -10,7 +17,7 @@ Features:
- Attach Nextcloud / ownCloud files to email.

Supported Versions:
- Nextcloud: 9, 10, 11, 12
- Nextcloud: 9, 10, 11, 12, 13
- ownCloud: 9, 9.1, 10

## Install
Expand Down Expand Up @@ -123,3 +130,6 @@ mysql -u root --password="${mysql_pwd}" "${occ_db}" -N -s \
-e "DELETE FROM oc_accounts WHERE uid = '${uid}' LIMIT 1"; \
done
```

## Issues
Zimbra Drive is an official Zimbra product - support is provided through the official Zimbra channels to both Open Source and Network Edition customers.
4 changes: 2 additions & 2 deletions nextcloud-app/appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
</description>
<licence>AGPL</licence>
<author>ZeXtras</author>
<version>0.8.18</version>
<version>0.8.23</version>
<namespace>ZimbraDrive</namespace>
<category>auth</category>
<category>integration</category>
Expand All @@ -42,7 +42,7 @@

<dependencies>
<owncloud min-version="9.0" max-version="10.0"/>
<nextcloud min-version="9" max-version="13"/>
<nextcloud min-version="9" max-version="15"/>
</dependencies>
<types>
<authentication/>
Expand Down
8 changes: 6 additions & 2 deletions nextcloud-app/appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
return [
'routes' => [
['name' => 'page#index', 'url' => '/', 'verb' => 'GET'],
['name' => 'zimbra_drive_api#searchRequest', 'url' => '/api/1.0/SearchRequest', 'verb' => 'POST'],
['name' => 'zimbra_drive_api#getAllFolders', 'url' => '/api/1.0/GetAllFolders', 'verb' => 'POST'],
['name' => 'zimbra_drive_api#searchRequestShareItemFiltered', 'url' => '/api/1.0/SearchRequest', 'verb' => 'POST'],
['name' => 'zimbra_drive_api#getAllFoldersShareItemFiltered', 'url' => '/api/1.0/GetAllFolders', 'verb' => 'POST'],
['name' => 'zimbra_drive_api#getFile', 'url' => '/api/1.0/GetFile', 'verb' => 'POST'],
['name' => 'zimbra_drive_api#uploadFile', 'url' => '/api/1.0/UploadFile', 'verb' => 'POST'],
['name' => 'zimbra_drive_api#delete', 'url' => '/api/1.0/Delete', 'verb' => 'POST'],
Expand All @@ -41,5 +41,9 @@
['name' => 'admin_api#disableZimbraAuthentication', 'url' => '/admin/DisableZimbraAuthentication', 'verb' => 'POST'],
['name' => 'test#all', 'url' => '/test/All', 'verb' => 'GET'],
['name' => 'test#connectivityTest', 'url' => '/test/ConnectivityTest', 'verb' => 'GET'],

['name' => 'zimbra_drive_api#getVersion', 'url' => '/api/2.0/GetVersion', 'verb' => 'POST'],
['name' => 'zimbra_drive_api#searchRequest', 'url' => '/api/2.0/SearchRequest', 'verb' => 'POST'],
['name' => 'zimbra_drive_api#getAllFolders', 'url' => '/api/2.0/GetAllFolders', 'verb' => 'POST'],
]
];
9 changes: 9 additions & 0 deletions nextcloud-app/js/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ var documentsSettings = {
documentsSettings.setValue('allow_zimbra_users_login', isEnabled);
},

setZimbraGroupToUsers: function (isEnabled) {
documentsSettings.setValue('set_zimbra_group', isEnabled);
},

initialize: function () {
setEnableZimbrasUsersUpdateHandler();
setAllowZimbrasUsersLoginUpdateHandler();
Expand All @@ -95,6 +99,7 @@ var documentsSettings = {
setZimbraUrlChangeHandler();
setZimbraPortChangeHandler();
setPreAuthKeyChangeHandler();
setZimbraGroupToUsersUpdateHandler();


function setEnableZimbrasUsersUpdateHandler() {
Expand Down Expand Up @@ -145,6 +150,10 @@ var documentsSettings = {
documentsSettings.setValue(this.name, this.value);
}
}

function setZimbraGroupToUsersUpdateHandler() {
addClickHandlerToCheckableItem("set_zimbra_group", documentsSettings.setZimbraGroupToUsers);
}
}
};

Expand Down
43 changes: 32 additions & 11 deletions nextcloud-app/lib/auth/abstractzimbrausersbackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ abstract class AbstractZimbraUsersBackend extends RetroCompatibleBackend
protected $userManager;
protected $groupManager;
protected $allow_zimbra_users_login;
protected $setZimbraGroupToUsers;
/** @var AccountManager */
private $accountManager;
/** @var ZimbraAuthenticationBackend */
Expand Down Expand Up @@ -72,6 +73,7 @@ public function __construct($server = null, $zimbraAuthenticationBackend = null)

$appSettings = new AppSettings($this->config);
$this->allow_zimbra_users_login = $appSettings->allowZimbraUsersLogin();
$this->setZimbraGroupToUsers = $appSettings->setZimbraGroupToUsers();
}

/**
Expand Down Expand Up @@ -121,7 +123,10 @@ private function setDefaultUserAttributes($zimbraUser){
*/
private function setDefaultGroups($user)
{
$this->insertUserInGroup($user, self::ZIMBRA_GROUP);
if ($this->setZimbraGroupToUsers)
{
$this->insertUserInGroup($user, self::ZIMBRA_GROUP);
}
$this->insertUserInGroup($user, $this->getEmailDomain($user->getEMailAddress()));
}

Expand All @@ -144,17 +149,33 @@ protected abstract function createUser($userId, $userDisplayName);
*/
private function restoreUserEmailIfChanged(User $user, $userEmail)
{
if( $user->getEMailAddress() !== $userEmail)
if( $this->getUserEmailAddress($user) !== $userEmail)
{
if(!is_null($this->accountManager)) //Nextcloud 11
{
$userData = $this->accountManager->getUser($user);
$userData[AccountManager::PROPERTY_EMAIL]['value'] = $userEmail;
$this->accountManager->updateUser($user, $userData);
} else
{
$user->setEMailAddress($userEmail);
}
$this->setUserEmailAddress($user, $userEmail);
}
}

private function getUserEmailAddress(User $user){
if(!is_null($this->accountManager)) //Nextcloud 11
{
$userData = $this->accountManager->getUser($user);
$userEmailAddress = $userData[AccountManager::PROPERTY_EMAIL]['value'];
} else
{
$userEmailAddress = $user->getEMailAddress();
}
return $userEmailAddress;
}

private function setUserEmailAddress(User $user, $userEmail){
if(!is_null($this->accountManager)) //Nextcloud 11
{
$userData = $this->accountManager->getUser($user);
$userData[AccountManager::PROPERTY_EMAIL]['value'] = $userEmail;
$this->accountManager->updateUser($user, $userData);
} else
{
$user->setEMailAddress($userEmail);
}
}

Expand Down
2 changes: 1 addition & 1 deletion nextcloud-app/lib/auth/zimbrausersbackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function __construct()
private function initializeOcUserZimbraBackend()
{
if (class_exists('OC\\User\\Account')) { //ownCloud 10 all user backend will be 'degraded' to authentication backend
$this->oc_user_zimbra_backend = new ZimbraUsersBackendPassword();
$this->oc_user_zimbra_backend = new ZimbraUsersBackendPassword($this);
} else {
$this->oc_user_zimbra_backend = new ZimbraUsersBackendInDb();
}
Expand Down
5 changes: 2 additions & 3 deletions nextcloud-app/lib/auth/zimbrausersbackendindb.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ protected function createUser($uid, $display_name)
*/
public function userExists($uid)
{
$sql='SELECT COUNT(*) FROM `*PREFIX*zimbradrive_users`'
$sql='SELECT COUNT(*) AS users_find FROM `*PREFIX*zimbradrive_users`'
. ' WHERE LOWER(`uid`) = LOWER(?)';

$statement = $this->databaseConnection->prepare($sql);
Expand All @@ -224,8 +224,7 @@ public function userExists($uid)

$row = $statement->fetch();
$statement->closeCursor();

return $row['COUNT(*)'] !== "0";
return $row['users_find'] != 0; //$row['users_find'] in mysql is a string, in postgresql is a integer
}
}

9 changes: 8 additions & 1 deletion nextcloud-app/lib/auth/zimbrausersbackendpassword.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@

class ZimbraUsersBackendPassword extends AbstractZimbraUsersBackend
{
/** @var ZimbraUsersBackend */
private $backend;
public function __construct($backend, $server = null, $zimbraAuthenticationBackend = null)
{
parent::__construct($server, $zimbraAuthenticationBackend);
$this->backend = $backend;
}

/**
* @param $userId
Expand All @@ -33,7 +40,7 @@ protected function createUser($userId, $userDisplayName)
{
parent::__construct();

$user = $this->userManager->createUser($userId, Random::string(255));
$user = $this->userManager->createUserFromBackend($userId, Random::string(255), $this->backend);
$user->setDisplayName($userDisplayName);
}

Expand Down
91 changes: 86 additions & 5 deletions nextcloud-app/lib/controller/zimbradriveapicontroller.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ public function __construct(
* @param $caseSensitive bool
* @return Response
*/
public function searchRequest($username, $token, $query, $types, $caseSensitive)
public function searchRequestShareItemFiltered($username, $token, $query, $types, $caseSensitive)
{
$this->logger->debug($username . ' call searchRequest.');
$this->logger->debug($username . ' call searchRequestShareItemFiltered.');
try {
$this->loginService->login($username, $token);
} catch (UnauthorizedException $unauthorizedException) {
Expand Down Expand Up @@ -119,6 +119,49 @@ public function searchRequest($username, $token, $query, $types, $caseSensitive)
return new JSONResponse($resultsNoShares);
}

/**
* @CORS
* @NoCSRFRequired
* @PublicPage
* @param $username
* @param $token
* @param $query
* @param $types
* @param $caseSensitive bool
* @return Response
*/
public function searchRequest($username, $token, $query, $types, $caseSensitive)
{
$this->logger->debug($username . ' call searchRequest.');
try {
$this->loginService->login($username, $token);
} catch (UnauthorizedException $unauthorizedException) {
$this->logUnauthorizedLogin($unauthorizedException);
return new EmptyResponse(Http::STATUS_UNAUTHORIZED);
}

$types = json_decode($types, false);
if($types === array('document'))
{
$types = array('file');
}
$caseSensitive = $caseSensitive === "true";

try {
$wantedFiles = $this->searchService->search($query, $caseSensitive);
} catch (BadRequestException $badRequestException) {
$this->logger->info($badRequestException->getMessage());
return new EmptyResponse(Http::STATUS_BAD_REQUEST);
}
catch (MethodNotAllowedException $methodNotAllowedException) {
$this->logger->info($methodNotAllowedException->getMessage());
return new EmptyResponse(Http::STATUS_METHOD_NOT_ALLOWED);
}

$results = $this->filterNodesByType($wantedFiles, $types);
return new JSONResponse($results);
}

/**
* @param $nodes array
* @param $allowedTypes array of string
Expand All @@ -138,6 +181,45 @@ private function filterNodesByType($nodes, $allowedTypes)

}

/**
* @param $node Node
* @param $validTypes array
* @return bool
*/
private function nodeHasAValidTypeShareItemFiltered($node, $validTypes)
{
return in_array($node[ResponseVarName::NODE_TYPE_VAR_NAME], $validTypes, true);
}

/**
* @CORS
* @NoCSRFRequired
* @PublicPage
* @param $username
* @param $token
* @return \OCP\AppFramework\Http\Response
*/
public function getAllFoldersShareItemFiltered($username, $token)
{
$this->logger->debug($username . ' call getAllFoldersShareItemFiltered.');
try {
$this->loginService->login($username, $token);
} catch (UnauthorizedException $unauthorizedException) {
$this->logUnauthorizedLogin($unauthorizedException);
return new EmptyResponse(Http::STATUS_UNAUTHORIZED);
}

try {
$searchedFolder = $this->storageService->getFolder(StorageService::ROOT);
} catch (Exception $exception) {
$this->logger->info($exception->getMessage());
return new EmptyResponse(Http::STATUS_FORBIDDEN);
}
$folderTree = $this->storageService->getFolderTreeAttributes($searchedFolder);
$folderTreeNoShare = $this->filterShareTreeNodes($folderTree);
return new JSONResponse($folderTreeNoShare);
}

/**
* @param $node Node
* @param $validTypes array
Expand Down Expand Up @@ -173,8 +255,7 @@ public function getAllFolders($username, $token)
return new EmptyResponse(Http::STATUS_FORBIDDEN);
}
$folderTree = $this->storageService->getFolderTreeAttributes($searchedFolder);
$folderTreeNoShare = $this->filterShareTreeNodes($folderTree);
return new JSONResponse($folderTreeNoShare);
return new JSONResponse($folderTree);
}

/**
Expand Down Expand Up @@ -275,7 +356,7 @@ public function move($username, $token, $source_path, $target_path)
catch (NotPermittedException $exception)
{
$this->logger->info($exception->getMessage());
return new EmptyResponse(Http::STATUS_METHOD_NOT_ALLOWED);
return new EmptyResponse(Http::STATUS_FORBIDDEN);
}
// catch (Exception $exception) {
// $this->logger->info($exception->getMessage());
Expand Down
Loading
Loading