@@ -31,24 +31,24 @@ |
||
31 | 31 | */ |
32 | 32 | class OAuth1 extends AuthMechanism { |
33 | 33 | |
34 | - public function __construct(IL10N $l) { |
|
35 | - $this |
|
36 | - ->setIdentifier('oauth1::oauth1') |
|
37 | - ->setScheme(self::SCHEME_OAUTH1) |
|
38 | - ->setText($l->t('OAuth1')) |
|
39 | - ->addParameters([ |
|
40 | - (new DefinitionParameter('configured', 'configured')) |
|
41 | - ->setType(DefinitionParameter::VALUE_HIDDEN), |
|
42 | - (new DefinitionParameter('app_key', $l->t('App key'))), |
|
43 | - (new DefinitionParameter('app_secret', $l->t('App secret'))) |
|
44 | - ->setType(DefinitionParameter::VALUE_PASSWORD), |
|
45 | - (new DefinitionParameter('token', 'token')) |
|
46 | - ->setType(DefinitionParameter::VALUE_HIDDEN), |
|
47 | - (new DefinitionParameter('token_secret', 'token_secret')) |
|
48 | - ->setType(DefinitionParameter::VALUE_HIDDEN), |
|
49 | - ]) |
|
50 | - ->addCustomJs('oauth1') |
|
51 | - ; |
|
52 | - } |
|
34 | + public function __construct(IL10N $l) { |
|
35 | + $this |
|
36 | + ->setIdentifier('oauth1::oauth1') |
|
37 | + ->setScheme(self::SCHEME_OAUTH1) |
|
38 | + ->setText($l->t('OAuth1')) |
|
39 | + ->addParameters([ |
|
40 | + (new DefinitionParameter('configured', 'configured')) |
|
41 | + ->setType(DefinitionParameter::VALUE_HIDDEN), |
|
42 | + (new DefinitionParameter('app_key', $l->t('App key'))), |
|
43 | + (new DefinitionParameter('app_secret', $l->t('App secret'))) |
|
44 | + ->setType(DefinitionParameter::VALUE_PASSWORD), |
|
45 | + (new DefinitionParameter('token', 'token')) |
|
46 | + ->setType(DefinitionParameter::VALUE_HIDDEN), |
|
47 | + (new DefinitionParameter('token_secret', 'token_secret')) |
|
48 | + ->setType(DefinitionParameter::VALUE_HIDDEN), |
|
49 | + ]) |
|
50 | + ->addCustomJs('oauth1') |
|
51 | + ; |
|
52 | + } |
|
53 | 53 | |
54 | 54 | } |
@@ -31,22 +31,22 @@ |
||
31 | 31 | */ |
32 | 32 | class OAuth2 extends AuthMechanism { |
33 | 33 | |
34 | - public function __construct(IL10N $l) { |
|
35 | - $this |
|
36 | - ->setIdentifier('oauth2::oauth2') |
|
37 | - ->setScheme(self::SCHEME_OAUTH2) |
|
38 | - ->setText($l->t('OAuth2')) |
|
39 | - ->addParameters([ |
|
40 | - (new DefinitionParameter('configured', 'configured')) |
|
41 | - ->setType(DefinitionParameter::VALUE_HIDDEN), |
|
42 | - (new DefinitionParameter('client_id', $l->t('Client ID'))), |
|
43 | - (new DefinitionParameter('client_secret', $l->t('Client secret'))) |
|
44 | - ->setType(DefinitionParameter::VALUE_PASSWORD), |
|
45 | - (new DefinitionParameter('token', 'token')) |
|
46 | - ->setType(DefinitionParameter::VALUE_HIDDEN), |
|
47 | - ]) |
|
48 | - ->addCustomJs('oauth2') |
|
49 | - ; |
|
50 | - } |
|
34 | + public function __construct(IL10N $l) { |
|
35 | + $this |
|
36 | + ->setIdentifier('oauth2::oauth2') |
|
37 | + ->setScheme(self::SCHEME_OAUTH2) |
|
38 | + ->setText($l->t('OAuth2')) |
|
39 | + ->addParameters([ |
|
40 | + (new DefinitionParameter('configured', 'configured')) |
|
41 | + ->setType(DefinitionParameter::VALUE_HIDDEN), |
|
42 | + (new DefinitionParameter('client_id', $l->t('Client ID'))), |
|
43 | + (new DefinitionParameter('client_secret', $l->t('Client secret'))) |
|
44 | + ->setType(DefinitionParameter::VALUE_PASSWORD), |
|
45 | + (new DefinitionParameter('token', 'token')) |
|
46 | + ->setType(DefinitionParameter::VALUE_HIDDEN), |
|
47 | + ]) |
|
48 | + ->addCustomJs('oauth2') |
|
49 | + ; |
|
50 | + } |
|
51 | 51 | |
52 | 52 | } |
@@ -28,10 +28,10 @@ |
||
28 | 28 | * For auth mechanisms where the user needs to provide credentials |
29 | 29 | */ |
30 | 30 | interface IUserProvided { |
31 | - /** |
|
32 | - * @param IUser $user the user for which to save the user provided options |
|
33 | - * @param int $mountId the mount id to save the options for |
|
34 | - * @param array $options the user provided options |
|
35 | - */ |
|
36 | - public function saveBackendOptions(IUser $user, $mountId, array $options); |
|
31 | + /** |
|
32 | + * @param IUser $user the user for which to save the user provided options |
|
33 | + * @param int $mountId the mount id to save the options for |
|
34 | + * @param array $options the user provided options |
|
35 | + */ |
|
36 | + public function saveBackendOptions(IUser $user, $mountId, array $options); |
|
37 | 37 | } |
@@ -31,17 +31,17 @@ |
||
31 | 31 | */ |
32 | 32 | class Rackspace extends AuthMechanism { |
33 | 33 | |
34 | - public function __construct(IL10N $l) { |
|
35 | - $this |
|
36 | - ->setIdentifier('openstack::rackspace') |
|
37 | - ->setScheme(self::SCHEME_OPENSTACK) |
|
38 | - ->setText($l->t('Rackspace')) |
|
39 | - ->addParameters([ |
|
40 | - (new DefinitionParameter('user', $l->t('Username'))), |
|
41 | - (new DefinitionParameter('key', $l->t('API key'))) |
|
42 | - ->setType(DefinitionParameter::VALUE_PASSWORD), |
|
43 | - ]) |
|
44 | - ; |
|
45 | - } |
|
34 | + public function __construct(IL10N $l) { |
|
35 | + $this |
|
36 | + ->setIdentifier('openstack::rackspace') |
|
37 | + ->setScheme(self::SCHEME_OPENSTACK) |
|
38 | + ->setText($l->t('Rackspace')) |
|
39 | + ->addParameters([ |
|
40 | + (new DefinitionParameter('user', $l->t('Username'))), |
|
41 | + (new DefinitionParameter('key', $l->t('API key'))) |
|
42 | + ->setType(DefinitionParameter::VALUE_PASSWORD), |
|
43 | + ]) |
|
44 | + ; |
|
45 | + } |
|
46 | 46 | |
47 | 47 | } |
@@ -31,19 +31,19 @@ |
||
31 | 31 | */ |
32 | 32 | class OpenStack extends AuthMechanism { |
33 | 33 | |
34 | - public function __construct(IL10N $l) { |
|
35 | - $this |
|
36 | - ->setIdentifier('openstack::openstack') |
|
37 | - ->setScheme(self::SCHEME_OPENSTACK) |
|
38 | - ->setText($l->t('OpenStack')) |
|
39 | - ->addParameters([ |
|
40 | - (new DefinitionParameter('user', $l->t('Username'))), |
|
41 | - (new DefinitionParameter('password', $l->t('Password'))) |
|
42 | - ->setType(DefinitionParameter::VALUE_PASSWORD), |
|
43 | - (new DefinitionParameter('tenant', $l->t('Tenant name'))), |
|
44 | - (new DefinitionParameter('url', $l->t('Identity endpoint URL'))), |
|
45 | - ]) |
|
46 | - ; |
|
47 | - } |
|
34 | + public function __construct(IL10N $l) { |
|
35 | + $this |
|
36 | + ->setIdentifier('openstack::openstack') |
|
37 | + ->setScheme(self::SCHEME_OPENSTACK) |
|
38 | + ->setText($l->t('OpenStack')) |
|
39 | + ->addParameters([ |
|
40 | + (new DefinitionParameter('user', $l->t('Username'))), |
|
41 | + (new DefinitionParameter('password', $l->t('Password'))) |
|
42 | + ->setType(DefinitionParameter::VALUE_PASSWORD), |
|
43 | + (new DefinitionParameter('tenant', $l->t('Tenant name'))), |
|
44 | + (new DefinitionParameter('url', $l->t('Identity endpoint URL'))), |
|
45 | + ]) |
|
46 | + ; |
|
47 | + } |
|
48 | 48 | |
49 | 49 | } |
@@ -57,7 +57,7 @@ |
||
57 | 57 | ; |
58 | 58 | } |
59 | 59 | |
60 | - public function manipulateStorageConfig(StorageConfig &$storage, IUser $user = null) { |
|
60 | + public function manipulateStorageConfig(StorageConfig & $storage, IUser $user = null) { |
|
61 | 61 | $auth = new RSACrypt(); |
62 | 62 | $auth->setPassword($this->config->getSystemValue('secret', '')); |
63 | 63 | if (!$auth->loadKey($storage->getBackendOption('private_key'))) { |
@@ -69,7 +69,7 @@ |
||
69 | 69 | /** |
70 | 70 | * Generate a keypair |
71 | 71 | * |
72 | - * @param int $keyLenth |
|
72 | + * @param integer $keyLength |
|
73 | 73 | * @return array ['privatekey' => $privateKey, 'publickey' => $publicKey] |
74 | 74 | */ |
75 | 75 | public function createKey($keyLength) { |
@@ -35,51 +35,51 @@ |
||
35 | 35 | */ |
36 | 36 | class RSA extends AuthMechanism { |
37 | 37 | |
38 | - /** @var IConfig */ |
|
39 | - private $config; |
|
38 | + /** @var IConfig */ |
|
39 | + private $config; |
|
40 | 40 | |
41 | - public function __construct(IL10N $l, IConfig $config) { |
|
42 | - $this->config = $config; |
|
41 | + public function __construct(IL10N $l, IConfig $config) { |
|
42 | + $this->config = $config; |
|
43 | 43 | |
44 | - $this |
|
45 | - ->setIdentifier('publickey::rsa') |
|
46 | - ->setScheme(self::SCHEME_PUBLICKEY) |
|
47 | - ->setText($l->t('RSA public key')) |
|
48 | - ->addParameters([ |
|
49 | - (new DefinitionParameter('user', $l->t('Username'))), |
|
50 | - (new DefinitionParameter('public_key', $l->t('Public key'))), |
|
51 | - (new DefinitionParameter('private_key', 'private_key')) |
|
52 | - ->setType(DefinitionParameter::VALUE_HIDDEN), |
|
53 | - ]) |
|
54 | - ->addCustomJs('public_key') |
|
55 | - ; |
|
56 | - } |
|
44 | + $this |
|
45 | + ->setIdentifier('publickey::rsa') |
|
46 | + ->setScheme(self::SCHEME_PUBLICKEY) |
|
47 | + ->setText($l->t('RSA public key')) |
|
48 | + ->addParameters([ |
|
49 | + (new DefinitionParameter('user', $l->t('Username'))), |
|
50 | + (new DefinitionParameter('public_key', $l->t('Public key'))), |
|
51 | + (new DefinitionParameter('private_key', 'private_key')) |
|
52 | + ->setType(DefinitionParameter::VALUE_HIDDEN), |
|
53 | + ]) |
|
54 | + ->addCustomJs('public_key') |
|
55 | + ; |
|
56 | + } |
|
57 | 57 | |
58 | - public function manipulateStorageConfig(StorageConfig &$storage, IUser $user = null) { |
|
59 | - $auth = new RSACrypt(); |
|
60 | - $auth->setPassword($this->config->getSystemValue('secret', '')); |
|
61 | - if (!$auth->loadKey($storage->getBackendOption('private_key'))) { |
|
62 | - throw new \RuntimeException('unable to load private key'); |
|
63 | - } |
|
64 | - $storage->setBackendOption('public_key_auth', $auth); |
|
65 | - } |
|
58 | + public function manipulateStorageConfig(StorageConfig &$storage, IUser $user = null) { |
|
59 | + $auth = new RSACrypt(); |
|
60 | + $auth->setPassword($this->config->getSystemValue('secret', '')); |
|
61 | + if (!$auth->loadKey($storage->getBackendOption('private_key'))) { |
|
62 | + throw new \RuntimeException('unable to load private key'); |
|
63 | + } |
|
64 | + $storage->setBackendOption('public_key_auth', $auth); |
|
65 | + } |
|
66 | 66 | |
67 | - /** |
|
68 | - * Generate a keypair |
|
69 | - * |
|
70 | - * @param int $keyLenth |
|
71 | - * @return array ['privatekey' => $privateKey, 'publickey' => $publicKey] |
|
72 | - */ |
|
73 | - public function createKey($keyLength) { |
|
74 | - $rsa = new RSACrypt(); |
|
75 | - $rsa->setPublicKeyFormat(RSACrypt::PUBLIC_FORMAT_OPENSSH); |
|
76 | - $rsa->setPassword($this->config->getSystemValue('secret', '')); |
|
67 | + /** |
|
68 | + * Generate a keypair |
|
69 | + * |
|
70 | + * @param int $keyLenth |
|
71 | + * @return array ['privatekey' => $privateKey, 'publickey' => $publicKey] |
|
72 | + */ |
|
73 | + public function createKey($keyLength) { |
|
74 | + $rsa = new RSACrypt(); |
|
75 | + $rsa->setPublicKeyFormat(RSACrypt::PUBLIC_FORMAT_OPENSSH); |
|
76 | + $rsa->setPassword($this->config->getSystemValue('secret', '')); |
|
77 | 77 | |
78 | - if ($keyLength !== 1024 && $keyLength !== 2048 && $keyLength !== 4096) { |
|
79 | - $keyLength = 1024; |
|
80 | - } |
|
78 | + if ($keyLength !== 1024 && $keyLength !== 2048 && $keyLength !== 4096) { |
|
79 | + $keyLength = 1024; |
|
80 | + } |
|
81 | 81 | |
82 | - return $rsa->createKey($keyLength); |
|
83 | - } |
|
82 | + return $rsa->createKey($keyLength); |
|
83 | + } |
|
84 | 84 | |
85 | 85 | } |
@@ -29,12 +29,12 @@ |
||
29 | 29 | */ |
30 | 30 | class Builtin extends AuthMechanism { |
31 | 31 | |
32 | - public function __construct(IL10N $l) { |
|
33 | - $this |
|
34 | - ->setIdentifier('builtin::builtin') |
|
35 | - ->setScheme(self::SCHEME_BUILTIN) |
|
36 | - ->setText($l->t('Builtin')) |
|
37 | - ; |
|
38 | - } |
|
32 | + public function __construct(IL10N $l) { |
|
33 | + $this |
|
34 | + ->setIdentifier('builtin::builtin') |
|
35 | + ->setScheme(self::SCHEME_BUILTIN) |
|
36 | + ->setText($l->t('Builtin')) |
|
37 | + ; |
|
38 | + } |
|
39 | 39 | |
40 | 40 | } |
@@ -51,71 +51,71 @@ |
||
51 | 51 | */ |
52 | 52 | class AuthMechanism implements \JsonSerializable { |
53 | 53 | |
54 | - /** Standard authentication schemes */ |
|
55 | - const SCHEME_NULL = 'null'; |
|
56 | - const SCHEME_BUILTIN = 'builtin'; |
|
57 | - const SCHEME_PASSWORD = 'password'; |
|
58 | - const SCHEME_OAUTH1 = 'oauth1'; |
|
59 | - const SCHEME_OAUTH2 = 'oauth2'; |
|
60 | - const SCHEME_PUBLICKEY = 'publickey'; |
|
61 | - const SCHEME_OPENSTACK = 'openstack'; |
|
54 | + /** Standard authentication schemes */ |
|
55 | + const SCHEME_NULL = 'null'; |
|
56 | + const SCHEME_BUILTIN = 'builtin'; |
|
57 | + const SCHEME_PASSWORD = 'password'; |
|
58 | + const SCHEME_OAUTH1 = 'oauth1'; |
|
59 | + const SCHEME_OAUTH2 = 'oauth2'; |
|
60 | + const SCHEME_PUBLICKEY = 'publickey'; |
|
61 | + const SCHEME_OPENSTACK = 'openstack'; |
|
62 | 62 | |
63 | - use VisibilityTrait; |
|
64 | - use FrontendDefinitionTrait; |
|
65 | - use StorageModifierTrait; |
|
66 | - use IdentifierTrait; |
|
63 | + use VisibilityTrait; |
|
64 | + use FrontendDefinitionTrait; |
|
65 | + use StorageModifierTrait; |
|
66 | + use IdentifierTrait; |
|
67 | 67 | |
68 | - /** @var string */ |
|
69 | - protected $scheme; |
|
68 | + /** @var string */ |
|
69 | + protected $scheme; |
|
70 | 70 | |
71 | - /** |
|
72 | - * Get the authentication scheme implemented |
|
73 | - * See self::SCHEME_* constants |
|
74 | - * |
|
75 | - * @return string |
|
76 | - */ |
|
77 | - public function getScheme() { |
|
78 | - return $this->scheme; |
|
79 | - } |
|
71 | + /** |
|
72 | + * Get the authentication scheme implemented |
|
73 | + * See self::SCHEME_* constants |
|
74 | + * |
|
75 | + * @return string |
|
76 | + */ |
|
77 | + public function getScheme() { |
|
78 | + return $this->scheme; |
|
79 | + } |
|
80 | 80 | |
81 | - /** |
|
82 | - * @param string $scheme |
|
83 | - * @return self |
|
84 | - */ |
|
85 | - public function setScheme($scheme) { |
|
86 | - $this->scheme = $scheme; |
|
87 | - return $this; |
|
88 | - } |
|
81 | + /** |
|
82 | + * @param string $scheme |
|
83 | + * @return self |
|
84 | + */ |
|
85 | + public function setScheme($scheme) { |
|
86 | + $this->scheme = $scheme; |
|
87 | + return $this; |
|
88 | + } |
|
89 | 89 | |
90 | - /** |
|
91 | - * Serialize into JSON for client-side JS |
|
92 | - * |
|
93 | - * @return array |
|
94 | - */ |
|
95 | - public function jsonSerialize() { |
|
96 | - $data = $this->jsonSerializeDefinition(); |
|
97 | - $data += $this->jsonSerializeIdentifier(); |
|
90 | + /** |
|
91 | + * Serialize into JSON for client-side JS |
|
92 | + * |
|
93 | + * @return array |
|
94 | + */ |
|
95 | + public function jsonSerialize() { |
|
96 | + $data = $this->jsonSerializeDefinition(); |
|
97 | + $data += $this->jsonSerializeIdentifier(); |
|
98 | 98 | |
99 | - $data['scheme'] = $this->getScheme(); |
|
100 | - $data['visibility'] = $this->getVisibility(); |
|
99 | + $data['scheme'] = $this->getScheme(); |
|
100 | + $data['visibility'] = $this->getVisibility(); |
|
101 | 101 | |
102 | - return $data; |
|
103 | - } |
|
102 | + return $data; |
|
103 | + } |
|
104 | 104 | |
105 | - /** |
|
106 | - * Check if parameters are satisfied in a StorageConfig |
|
107 | - * |
|
108 | - * @param StorageConfig $storage |
|
109 | - * @return bool |
|
110 | - */ |
|
111 | - public function validateStorage(StorageConfig $storage) { |
|
112 | - // does the backend actually support this scheme |
|
113 | - $supportedSchemes = $storage->getBackend()->getAuthSchemes(); |
|
114 | - if (!isset($supportedSchemes[$this->getScheme()])) { |
|
115 | - return false; |
|
116 | - } |
|
105 | + /** |
|
106 | + * Check if parameters are satisfied in a StorageConfig |
|
107 | + * |
|
108 | + * @param StorageConfig $storage |
|
109 | + * @return bool |
|
110 | + */ |
|
111 | + public function validateStorage(StorageConfig $storage) { |
|
112 | + // does the backend actually support this scheme |
|
113 | + $supportedSchemes = $storage->getBackend()->getAuthSchemes(); |
|
114 | + if (!isset($supportedSchemes[$this->getScheme()])) { |
|
115 | + return false; |
|
116 | + } |
|
117 | 117 | |
118 | - return $this->validateStorageDefinition($storage); |
|
119 | - } |
|
118 | + return $this->validateStorageDefinition($storage); |
|
119 | + } |
|
120 | 120 | |
121 | 121 | } |
@@ -29,12 +29,12 @@ |
||
29 | 29 | */ |
30 | 30 | class NullMechanism extends AuthMechanism { |
31 | 31 | |
32 | - public function __construct(IL10N $l) { |
|
33 | - $this |
|
34 | - ->setIdentifier('null::null') |
|
35 | - ->setScheme(self::SCHEME_NULL) |
|
36 | - ->setText($l->t('None')) |
|
37 | - ; |
|
38 | - } |
|
32 | + public function __construct(IL10N $l) { |
|
33 | + $this |
|
34 | + ->setIdentifier('null::null') |
|
35 | + ->setScheme(self::SCHEME_NULL) |
|
36 | + ->setText($l->t('None')) |
|
37 | + ; |
|
38 | + } |
|
39 | 39 | |
40 | 40 | } |