2014-12-19 20:23:24 +03:00
|
|
|
<?php
|
|
|
|
/**
|
2015-03-26 13:44:34 +03:00
|
|
|
* @author Morris Jobke <hey@morrisjobke.de>
|
2016-03-01 19:25:15 +03:00
|
|
|
* @author Robin Appelman <icewind@owncloud.com>
|
2016-01-12 17:02:16 +03:00
|
|
|
* @author Robin McCorkell <robin@mccorkell.me.uk>
|
2015-10-26 15:54:55 +03:00
|
|
|
* @author Roeland Jago Douma <rullzer@owncloud.com>
|
2015-03-26 13:44:34 +03:00
|
|
|
* @author Ross Nicoll <jrn@jrn.me.uk>
|
|
|
|
* @author Vincent Petry <pvince81@owncloud.com>
|
|
|
|
*
|
2016-01-12 17:02:16 +03:00
|
|
|
* @copyright Copyright (c) 2016, ownCloud, Inc.
|
2015-03-26 13:44:34 +03:00
|
|
|
* @license AGPL-3.0
|
|
|
|
*
|
|
|
|
* This code is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License, version 3,
|
|
|
|
* as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License, version 3,
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
|
|
|
*
|
2014-12-19 20:23:24 +03:00
|
|
|
*/
|
2015-02-26 13:37:37 +03:00
|
|
|
|
2015-03-21 22:12:55 +03:00
|
|
|
namespace OCA\Files_External\AppInfo;
|
2014-12-19 20:23:24 +03:00
|
|
|
|
|
|
|
use \OCP\AppFramework\App;
|
2016-01-13 17:29:53 +03:00
|
|
|
use OCP\AppFramework\IAppContainer;
|
2014-12-19 20:23:24 +03:00
|
|
|
use \OCP\IContainer;
|
2015-08-11 20:45:07 +03:00
|
|
|
use \OCA\Files_External\Service\BackendService;
|
2016-05-11 21:34:57 +03:00
|
|
|
use \OCA\Files_External\Lib\Config\IBackendProvider;
|
|
|
|
use \OCA\Files_External\Lib\Config\IAuthMechanismProvider;
|
2014-12-19 20:23:24 +03:00
|
|
|
|
2014-10-31 13:41:07 +03:00
|
|
|
/**
|
2016-05-13 12:22:28 +03:00
|
|
|
* @package OCA\Files_External\AppInfo
|
2014-10-31 13:41:07 +03:00
|
|
|
*/
|
2016-05-11 21:34:57 +03:00
|
|
|
class Application extends App implements IBackendProvider, IAuthMechanismProvider {
|
|
|
|
|
2016-01-13 17:29:53 +03:00
|
|
|
public function __construct(array $urlParams = array()) {
|
2014-12-19 20:23:24 +03:00
|
|
|
parent::__construct('files_external', $urlParams);
|
2014-10-31 13:41:07 +03:00
|
|
|
|
2016-05-11 21:34:57 +03:00
|
|
|
$container = $this->getContainer();
|
|
|
|
|
|
|
|
$container->registerService('OCP\Files\Config\IUserMountCache', function (IAppContainer $c) {
|
2016-01-13 17:29:53 +03:00
|
|
|
return $c->getServer()->query('UserMountCache');
|
|
|
|
});
|
|
|
|
|
2016-05-11 21:34:57 +03:00
|
|
|
$backendService = $container->query('OCA\\Files_External\\Service\\BackendService');
|
|
|
|
$backendService->registerBackendProvider($this);
|
|
|
|
$backendService->registerAuthMechanismProvider($this);
|
2015-08-30 17:00:22 +03:00
|
|
|
|
|
|
|
// app developers: do NOT depend on this! it will disappear with oC 9.0!
|
|
|
|
\OC::$server->getEventDispatcher()->dispatch(
|
|
|
|
'OCA\\Files_External::loadAdditionalBackends'
|
|
|
|
);
|
2014-12-19 20:23:24 +03:00
|
|
|
}
|
2015-08-11 20:45:07 +03:00
|
|
|
|
2016-01-15 01:13:28 +03:00
|
|
|
/**
|
|
|
|
* Register settings templates
|
|
|
|
*/
|
|
|
|
public function registerSettings() {
|
|
|
|
$container = $this->getContainer();
|
|
|
|
$backendService = $container->query('OCA\\Files_External\\Service\\BackendService');
|
|
|
|
|
|
|
|
\OCP\App::registerAdmin('files_external', 'settings');
|
2016-03-17 01:06:49 +03:00
|
|
|
\OCP\App::registerPersonal('files_external', 'personal');
|
2016-01-15 01:13:28 +03:00
|
|
|
}
|
|
|
|
|
2015-08-11 20:45:07 +03:00
|
|
|
/**
|
2016-05-11 21:34:57 +03:00
|
|
|
* @{inheritdoc}
|
2015-08-11 20:45:07 +03:00
|
|
|
*/
|
2016-05-11 21:34:57 +03:00
|
|
|
public function getBackends() {
|
2015-08-11 20:45:07 +03:00
|
|
|
$container = $this->getContainer();
|
2015-08-12 23:55:43 +03:00
|
|
|
|
2016-05-11 21:34:57 +03:00
|
|
|
$backends = [
|
2015-08-12 23:55:43 +03:00
|
|
|
$container->query('OCA\Files_External\Lib\Backend\Local'),
|
2015-08-13 00:07:20 +03:00
|
|
|
$container->query('OCA\Files_External\Lib\Backend\FTP'),
|
2015-08-13 00:16:46 +03:00
|
|
|
$container->query('OCA\Files_External\Lib\Backend\DAV'),
|
2015-08-13 00:17:50 +03:00
|
|
|
$container->query('OCA\Files_External\Lib\Backend\OwnCloud'),
|
2015-08-13 00:19:32 +03:00
|
|
|
$container->query('OCA\Files_External\Lib\Backend\SFTP'),
|
2015-08-12 23:58:22 +03:00
|
|
|
$container->query('OCA\Files_External\Lib\Backend\AmazonS3'),
|
2015-08-13 00:03:41 +03:00
|
|
|
$container->query('OCA\Files_External\Lib\Backend\Dropbox'),
|
2015-08-13 00:09:20 +03:00
|
|
|
$container->query('OCA\Files_External\Lib\Backend\Google'),
|
2015-08-13 00:10:30 +03:00
|
|
|
$container->query('OCA\Files_External\Lib\Backend\Swift'),
|
2015-08-13 00:20:08 +03:00
|
|
|
$container->query('OCA\Files_External\Lib\Backend\SFTP_Key'),
|
2016-05-11 21:34:57 +03:00
|
|
|
];
|
2015-08-13 00:13:27 +03:00
|
|
|
|
|
|
|
if (!\OC_Util::runningOnWindows()) {
|
2016-05-11 21:34:57 +03:00
|
|
|
$backends += [
|
2015-08-13 00:13:27 +03:00
|
|
|
$container->query('OCA\Files_External\Lib\Backend\SMB'),
|
2015-08-13 00:14:42 +03:00
|
|
|
$container->query('OCA\Files_External\Lib\Backend\SMB_OC'),
|
2016-05-11 21:34:57 +03:00
|
|
|
];
|
2015-08-13 00:13:27 +03:00
|
|
|
}
|
2016-05-11 21:34:57 +03:00
|
|
|
|
|
|
|
return $backends;
|
2015-08-11 20:45:07 +03:00
|
|
|
}
|
|
|
|
|
Authentication mechanisms for external storage backends
A backend can now specify generic authentication schemes that it
supports, instead of specifying the parameters for its authentication
method directly. This allows multiple authentication mechanisms to be
implemented for a single scheme, providing altered functionality.
This commit introduces the backend framework for this feature, and so at
this point the UI will be broken as the frontend does not specify the
required information.
Terminology:
- authentication scheme
Parameter interface for the authentication method. A backend
supporting the 'password' scheme accepts two parameters, 'user' and
'password'.
- authentication mechanism
Specific mechanism implementing a scheme. Basic mechanisms may
forward configuration options directly to the backend, more advanced
ones may lookup parameters or retrieve them from the session
New dropdown selector for external storage configurations to select the
authentication mechanism to be used.
Authentication mechanisms can have visibilities, just like backends.
The API was extended too to make it easier to add/remove visibilities.
In addition, the concept of 'allowed visibility' has been introduced, so
a backend/auth mechanism can force a maximum visibility level (e.g.
Local storage type) that cannot be overridden by configuration in the
web UI.
An authentication mechanism is a fully instantiated implementation. This
allows an implementation to have dependencies injected into it, e.g. an
\OCP\IDB for database operations.
When a StorageConfig is being prepared for mounting, the authentication
mechanism implementation has manipulateStorage() called,
which inserts the relevant authentication method options into the
storage ready for mounting.
2015-08-12 12:54:03 +03:00
|
|
|
/**
|
2016-05-11 21:34:57 +03:00
|
|
|
* @{inheritdoc}
|
Authentication mechanisms for external storage backends
A backend can now specify generic authentication schemes that it
supports, instead of specifying the parameters for its authentication
method directly. This allows multiple authentication mechanisms to be
implemented for a single scheme, providing altered functionality.
This commit introduces the backend framework for this feature, and so at
this point the UI will be broken as the frontend does not specify the
required information.
Terminology:
- authentication scheme
Parameter interface for the authentication method. A backend
supporting the 'password' scheme accepts two parameters, 'user' and
'password'.
- authentication mechanism
Specific mechanism implementing a scheme. Basic mechanisms may
forward configuration options directly to the backend, more advanced
ones may lookup parameters or retrieve them from the session
New dropdown selector for external storage configurations to select the
authentication mechanism to be used.
Authentication mechanisms can have visibilities, just like backends.
The API was extended too to make it easier to add/remove visibilities.
In addition, the concept of 'allowed visibility' has been introduced, so
a backend/auth mechanism can force a maximum visibility level (e.g.
Local storage type) that cannot be overridden by configuration in the
web UI.
An authentication mechanism is a fully instantiated implementation. This
allows an implementation to have dependencies injected into it, e.g. an
\OCP\IDB for database operations.
When a StorageConfig is being prepared for mounting, the authentication
mechanism implementation has manipulateStorage() called,
which inserts the relevant authentication method options into the
storage ready for mounting.
2015-08-12 12:54:03 +03:00
|
|
|
*/
|
2016-05-11 21:34:57 +03:00
|
|
|
public function getAuthMechanisms() {
|
Authentication mechanisms for external storage backends
A backend can now specify generic authentication schemes that it
supports, instead of specifying the parameters for its authentication
method directly. This allows multiple authentication mechanisms to be
implemented for a single scheme, providing altered functionality.
This commit introduces the backend framework for this feature, and so at
this point the UI will be broken as the frontend does not specify the
required information.
Terminology:
- authentication scheme
Parameter interface for the authentication method. A backend
supporting the 'password' scheme accepts two parameters, 'user' and
'password'.
- authentication mechanism
Specific mechanism implementing a scheme. Basic mechanisms may
forward configuration options directly to the backend, more advanced
ones may lookup parameters or retrieve them from the session
New dropdown selector for external storage configurations to select the
authentication mechanism to be used.
Authentication mechanisms can have visibilities, just like backends.
The API was extended too to make it easier to add/remove visibilities.
In addition, the concept of 'allowed visibility' has been introduced, so
a backend/auth mechanism can force a maximum visibility level (e.g.
Local storage type) that cannot be overridden by configuration in the
web UI.
An authentication mechanism is a fully instantiated implementation. This
allows an implementation to have dependencies injected into it, e.g. an
\OCP\IDB for database operations.
When a StorageConfig is being prepared for mounting, the authentication
mechanism implementation has manipulateStorage() called,
which inserts the relevant authentication method options into the
storage ready for mounting.
2015-08-12 12:54:03 +03:00
|
|
|
$container = $this->getContainer();
|
|
|
|
|
2016-05-11 21:34:57 +03:00
|
|
|
return [
|
Authentication mechanisms for external storage backends
A backend can now specify generic authentication schemes that it
supports, instead of specifying the parameters for its authentication
method directly. This allows multiple authentication mechanisms to be
implemented for a single scheme, providing altered functionality.
This commit introduces the backend framework for this feature, and so at
this point the UI will be broken as the frontend does not specify the
required information.
Terminology:
- authentication scheme
Parameter interface for the authentication method. A backend
supporting the 'password' scheme accepts two parameters, 'user' and
'password'.
- authentication mechanism
Specific mechanism implementing a scheme. Basic mechanisms may
forward configuration options directly to the backend, more advanced
ones may lookup parameters or retrieve them from the session
New dropdown selector for external storage configurations to select the
authentication mechanism to be used.
Authentication mechanisms can have visibilities, just like backends.
The API was extended too to make it easier to add/remove visibilities.
In addition, the concept of 'allowed visibility' has been introduced, so
a backend/auth mechanism can force a maximum visibility level (e.g.
Local storage type) that cannot be overridden by configuration in the
web UI.
An authentication mechanism is a fully instantiated implementation. This
allows an implementation to have dependencies injected into it, e.g. an
\OCP\IDB for database operations.
When a StorageConfig is being prepared for mounting, the authentication
mechanism implementation has manipulateStorage() called,
which inserts the relevant authentication method options into the
storage ready for mounting.
2015-08-12 12:54:03 +03:00
|
|
|
// AuthMechanism::SCHEME_NULL mechanism
|
|
|
|
$container->query('OCA\Files_External\Lib\Auth\NullMechanism'),
|
2015-08-12 11:21:09 +03:00
|
|
|
|
|
|
|
// AuthMechanism::SCHEME_BUILTIN mechanism
|
|
|
|
$container->query('OCA\Files_External\Lib\Auth\Builtin'),
|
2015-08-13 00:05:17 +03:00
|
|
|
|
|
|
|
// AuthMechanism::SCHEME_PASSWORD mechanisms
|
|
|
|
$container->query('OCA\Files_External\Lib\Auth\Password\Password'),
|
|
|
|
$container->query('OCA\Files_External\Lib\Auth\Password\SessionCredentials'),
|
2015-08-12 23:58:22 +03:00
|
|
|
|
2015-08-13 00:03:41 +03:00
|
|
|
// AuthMechanism::SCHEME_OAUTH1 mechanisms
|
|
|
|
$container->query('OCA\Files_External\Lib\Auth\OAuth1\OAuth1'),
|
|
|
|
|
2015-08-13 00:09:20 +03:00
|
|
|
// AuthMechanism::SCHEME_OAUTH2 mechanisms
|
|
|
|
$container->query('OCA\Files_External\Lib\Auth\OAuth2\OAuth2'),
|
|
|
|
|
2015-08-13 00:20:08 +03:00
|
|
|
// AuthMechanism::SCHEME_PUBLICKEY mechanisms
|
|
|
|
$container->query('OCA\Files_External\Lib\Auth\PublicKey\RSA'),
|
|
|
|
|
2015-08-13 00:10:30 +03:00
|
|
|
// AuthMechanism::SCHEME_OPENSTACK mechanisms
|
|
|
|
$container->query('OCA\Files_External\Lib\Auth\OpenStack\OpenStack'),
|
|
|
|
$container->query('OCA\Files_External\Lib\Auth\OpenStack\Rackspace'),
|
|
|
|
|
2015-08-12 23:58:22 +03:00
|
|
|
// Specialized mechanisms
|
|
|
|
$container->query('OCA\Files_External\Lib\Auth\AmazonS3\AccessKey'),
|
2016-05-11 21:34:57 +03:00
|
|
|
];
|
Authentication mechanisms for external storage backends
A backend can now specify generic authentication schemes that it
supports, instead of specifying the parameters for its authentication
method directly. This allows multiple authentication mechanisms to be
implemented for a single scheme, providing altered functionality.
This commit introduces the backend framework for this feature, and so at
this point the UI will be broken as the frontend does not specify the
required information.
Terminology:
- authentication scheme
Parameter interface for the authentication method. A backend
supporting the 'password' scheme accepts two parameters, 'user' and
'password'.
- authentication mechanism
Specific mechanism implementing a scheme. Basic mechanisms may
forward configuration options directly to the backend, more advanced
ones may lookup parameters or retrieve them from the session
New dropdown selector for external storage configurations to select the
authentication mechanism to be used.
Authentication mechanisms can have visibilities, just like backends.
The API was extended too to make it easier to add/remove visibilities.
In addition, the concept of 'allowed visibility' has been introduced, so
a backend/auth mechanism can force a maximum visibility level (e.g.
Local storage type) that cannot be overridden by configuration in the
web UI.
An authentication mechanism is a fully instantiated implementation. This
allows an implementation to have dependencies injected into it, e.g. an
\OCP\IDB for database operations.
When a StorageConfig is being prepared for mounting, the authentication
mechanism implementation has manipulateStorage() called,
which inserts the relevant authentication method options into the
storage ready for mounting.
2015-08-12 12:54:03 +03:00
|
|
|
}
|
|
|
|
|
2014-12-19 20:23:24 +03:00
|
|
|
}
|