@@ -26,71 +26,71 @@ |
||
26 | 26 | |
27 | 27 | class Setting implements ISetting { |
28 | 28 | |
29 | - /** @var IL10N */ |
|
30 | - protected $l; |
|
29 | + /** @var IL10N */ |
|
30 | + protected $l; |
|
31 | 31 | |
32 | - /** |
|
33 | - * @param IL10N $l10n |
|
34 | - */ |
|
35 | - public function __construct(IL10N $l10n) { |
|
36 | - $this->l = $l10n; |
|
37 | - } |
|
32 | + /** |
|
33 | + * @param IL10N $l10n |
|
34 | + */ |
|
35 | + public function __construct(IL10N $l10n) { |
|
36 | + $this->l = $l10n; |
|
37 | + } |
|
38 | 38 | |
39 | - /** |
|
40 | - * @return string Lowercase a-z and underscore only identifier |
|
41 | - * @since 11.0.0 |
|
42 | - */ |
|
43 | - public function getIdentifier() { |
|
44 | - return 'personal_settings'; |
|
45 | - } |
|
39 | + /** |
|
40 | + * @return string Lowercase a-z and underscore only identifier |
|
41 | + * @since 11.0.0 |
|
42 | + */ |
|
43 | + public function getIdentifier() { |
|
44 | + return 'personal_settings'; |
|
45 | + } |
|
46 | 46 | |
47 | - /** |
|
48 | - * @return string A translated string |
|
49 | - * @since 11.0.0 |
|
50 | - */ |
|
51 | - public function getName() { |
|
52 | - return $this->l->t('Your <strong>password</strong> or <strong>email</strong> was modified'); |
|
53 | - } |
|
47 | + /** |
|
48 | + * @return string A translated string |
|
49 | + * @since 11.0.0 |
|
50 | + */ |
|
51 | + public function getName() { |
|
52 | + return $this->l->t('Your <strong>password</strong> or <strong>email</strong> was modified'); |
|
53 | + } |
|
54 | 54 | |
55 | - /** |
|
56 | - * @return int whether the filter should be rather on the top or bottom of |
|
57 | - * the admin section. The filters are arranged in ascending order of the |
|
58 | - * priority values. It is required to return a value between 0 and 100. |
|
59 | - * @since 11.0.0 |
|
60 | - */ |
|
61 | - public function getPriority() { |
|
62 | - return 0; |
|
63 | - } |
|
55 | + /** |
|
56 | + * @return int whether the filter should be rather on the top or bottom of |
|
57 | + * the admin section. The filters are arranged in ascending order of the |
|
58 | + * priority values. It is required to return a value between 0 and 100. |
|
59 | + * @since 11.0.0 |
|
60 | + */ |
|
61 | + public function getPriority() { |
|
62 | + return 0; |
|
63 | + } |
|
64 | 64 | |
65 | - /** |
|
66 | - * @return bool True when the option can be changed for the stream |
|
67 | - * @since 11.0.0 |
|
68 | - */ |
|
69 | - public function canChangeStream() { |
|
70 | - return false; |
|
71 | - } |
|
65 | + /** |
|
66 | + * @return bool True when the option can be changed for the stream |
|
67 | + * @since 11.0.0 |
|
68 | + */ |
|
69 | + public function canChangeStream() { |
|
70 | + return false; |
|
71 | + } |
|
72 | 72 | |
73 | - /** |
|
74 | - * @return bool True when the option can be changed for the stream |
|
75 | - * @since 11.0.0 |
|
76 | - */ |
|
77 | - public function isDefaultEnabledStream() { |
|
78 | - return true; |
|
79 | - } |
|
73 | + /** |
|
74 | + * @return bool True when the option can be changed for the stream |
|
75 | + * @since 11.0.0 |
|
76 | + */ |
|
77 | + public function isDefaultEnabledStream() { |
|
78 | + return true; |
|
79 | + } |
|
80 | 80 | |
81 | - /** |
|
82 | - * @return bool True when the option can be changed for the mail |
|
83 | - * @since 11.0.0 |
|
84 | - */ |
|
85 | - public function canChangeMail() { |
|
86 | - return false; |
|
87 | - } |
|
81 | + /** |
|
82 | + * @return bool True when the option can be changed for the mail |
|
83 | + * @since 11.0.0 |
|
84 | + */ |
|
85 | + public function canChangeMail() { |
|
86 | + return false; |
|
87 | + } |
|
88 | 88 | |
89 | - /** |
|
90 | - * @return bool True when the option can be changed for the stream |
|
91 | - * @since 11.0.0 |
|
92 | - */ |
|
93 | - public function isDefaultEnabledMail() { |
|
94 | - return false; |
|
95 | - } |
|
89 | + /** |
|
90 | + * @return bool True when the option can be changed for the stream |
|
91 | + * @since 11.0.0 |
|
92 | + */ |
|
93 | + public function isDefaultEnabledMail() { |
|
94 | + return false; |
|
95 | + } |
|
96 | 96 | } |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | public function beforeController($controller, $methodName) { |
62 | 62 | parent::beforeController($controller, $methodName); |
63 | 63 | |
64 | - if($this->reflector->hasAnnotation('BruteForceProtection')) { |
|
64 | + if ($this->reflector->hasAnnotation('BruteForceProtection')) { |
|
65 | 65 | $action = $this->reflector->getAnnotationParameter('BruteForceProtection', 'action'); |
66 | 66 | $this->throttler->sleepDelay($this->request->getRemoteAddress(), $action); |
67 | 67 | } |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | * {@inheritDoc} |
72 | 72 | */ |
73 | 73 | public function afterController($controller, $methodName, Response $response) { |
74 | - if($this->reflector->hasAnnotation('BruteForceProtection') && $response->isThrottled()) { |
|
74 | + if ($this->reflector->hasAnnotation('BruteForceProtection') && $response->isThrottled()) { |
|
75 | 75 | $action = $this->reflector->getAnnotationParameter('BruteForceProtection', 'action'); |
76 | 76 | $ip = $this->request->getRemoteAddress(); |
77 | 77 | $this->throttler->sleepDelay($ip, $action); |
@@ -35,49 +35,49 @@ |
||
35 | 35 | * @package OC\AppFramework\Middleware\Security |
36 | 36 | */ |
37 | 37 | class BruteForceMiddleware extends Middleware { |
38 | - /** @var ControllerMethodReflector */ |
|
39 | - private $reflector; |
|
40 | - /** @var Throttler */ |
|
41 | - private $throttler; |
|
42 | - /** @var IRequest */ |
|
43 | - private $request; |
|
38 | + /** @var ControllerMethodReflector */ |
|
39 | + private $reflector; |
|
40 | + /** @var Throttler */ |
|
41 | + private $throttler; |
|
42 | + /** @var IRequest */ |
|
43 | + private $request; |
|
44 | 44 | |
45 | - /** |
|
46 | - * @param ControllerMethodReflector $controllerMethodReflector |
|
47 | - * @param Throttler $throttler |
|
48 | - * @param IRequest $request |
|
49 | - */ |
|
50 | - public function __construct(ControllerMethodReflector $controllerMethodReflector, |
|
51 | - Throttler $throttler, |
|
52 | - IRequest $request) { |
|
53 | - $this->reflector = $controllerMethodReflector; |
|
54 | - $this->throttler = $throttler; |
|
55 | - $this->request = $request; |
|
56 | - } |
|
45 | + /** |
|
46 | + * @param ControllerMethodReflector $controllerMethodReflector |
|
47 | + * @param Throttler $throttler |
|
48 | + * @param IRequest $request |
|
49 | + */ |
|
50 | + public function __construct(ControllerMethodReflector $controllerMethodReflector, |
|
51 | + Throttler $throttler, |
|
52 | + IRequest $request) { |
|
53 | + $this->reflector = $controllerMethodReflector; |
|
54 | + $this->throttler = $throttler; |
|
55 | + $this->request = $request; |
|
56 | + } |
|
57 | 57 | |
58 | - /** |
|
59 | - * {@inheritDoc} |
|
60 | - */ |
|
61 | - public function beforeController($controller, $methodName) { |
|
62 | - parent::beforeController($controller, $methodName); |
|
58 | + /** |
|
59 | + * {@inheritDoc} |
|
60 | + */ |
|
61 | + public function beforeController($controller, $methodName) { |
|
62 | + parent::beforeController($controller, $methodName); |
|
63 | 63 | |
64 | - if($this->reflector->hasAnnotation('BruteForceProtection')) { |
|
65 | - $action = $this->reflector->getAnnotationParameter('BruteForceProtection', 'action'); |
|
66 | - $this->throttler->sleepDelay($this->request->getRemoteAddress(), $action); |
|
67 | - } |
|
68 | - } |
|
64 | + if($this->reflector->hasAnnotation('BruteForceProtection')) { |
|
65 | + $action = $this->reflector->getAnnotationParameter('BruteForceProtection', 'action'); |
|
66 | + $this->throttler->sleepDelay($this->request->getRemoteAddress(), $action); |
|
67 | + } |
|
68 | + } |
|
69 | 69 | |
70 | - /** |
|
71 | - * {@inheritDoc} |
|
72 | - */ |
|
73 | - public function afterController($controller, $methodName, Response $response) { |
|
74 | - if($this->reflector->hasAnnotation('BruteForceProtection') && $response->isThrottled()) { |
|
75 | - $action = $this->reflector->getAnnotationParameter('BruteForceProtection', 'action'); |
|
76 | - $ip = $this->request->getRemoteAddress(); |
|
77 | - $this->throttler->sleepDelay($ip, $action); |
|
78 | - $this->throttler->registerAttempt($action, $ip, $response->getThrottleMetadata()); |
|
79 | - } |
|
70 | + /** |
|
71 | + * {@inheritDoc} |
|
72 | + */ |
|
73 | + public function afterController($controller, $methodName, Response $response) { |
|
74 | + if($this->reflector->hasAnnotation('BruteForceProtection') && $response->isThrottled()) { |
|
75 | + $action = $this->reflector->getAnnotationParameter('BruteForceProtection', 'action'); |
|
76 | + $ip = $this->request->getRemoteAddress(); |
|
77 | + $this->throttler->sleepDelay($ip, $action); |
|
78 | + $this->throttler->registerAttempt($action, $ip, $response->getThrottleMetadata()); |
|
79 | + } |
|
80 | 80 | |
81 | - return parent::afterController($controller, $methodName, $response); |
|
82 | - } |
|
81 | + return parent::afterController($controller, $methodName, $response); |
|
82 | + } |
|
83 | 83 | } |
@@ -43,185 +43,185 @@ |
||
43 | 43 | * User storages controller |
44 | 44 | */ |
45 | 45 | class UserStoragesController extends StoragesController { |
46 | - /** |
|
47 | - * @var IUserSession |
|
48 | - */ |
|
49 | - private $userSession; |
|
50 | - |
|
51 | - /** |
|
52 | - * Creates a new user storages controller. |
|
53 | - * |
|
54 | - * @param string $AppName application name |
|
55 | - * @param IRequest $request request object |
|
56 | - * @param IL10N $l10n l10n service |
|
57 | - * @param UserStoragesService $userStoragesService storage service |
|
58 | - * @param IUserSession $userSession |
|
59 | - * @param ILogger $logger |
|
60 | - */ |
|
61 | - public function __construct( |
|
62 | - $AppName, |
|
63 | - IRequest $request, |
|
64 | - IL10N $l10n, |
|
65 | - UserStoragesService $userStoragesService, |
|
66 | - IUserSession $userSession, |
|
67 | - ILogger $logger |
|
68 | - ) { |
|
69 | - parent::__construct( |
|
70 | - $AppName, |
|
71 | - $request, |
|
72 | - $l10n, |
|
73 | - $userStoragesService, |
|
74 | - $logger |
|
75 | - ); |
|
76 | - $this->userSession = $userSession; |
|
77 | - } |
|
78 | - |
|
79 | - protected function manipulateStorageConfig(StorageConfig $storage) { |
|
80 | - /** @var AuthMechanism */ |
|
81 | - $authMechanism = $storage->getAuthMechanism(); |
|
82 | - $authMechanism->manipulateStorageConfig($storage, $this->userSession->getUser()); |
|
83 | - /** @var Backend */ |
|
84 | - $backend = $storage->getBackend(); |
|
85 | - $backend->manipulateStorageConfig($storage, $this->userSession->getUser()); |
|
86 | - } |
|
87 | - |
|
88 | - /** |
|
89 | - * Get all storage entries |
|
90 | - * |
|
91 | - * @NoAdminRequired |
|
92 | - * |
|
93 | - * @return DataResponse |
|
94 | - */ |
|
95 | - public function index() { |
|
96 | - return parent::index(); |
|
97 | - } |
|
98 | - |
|
99 | - /** |
|
100 | - * Return storage |
|
101 | - * |
|
102 | - * @NoAdminRequired |
|
103 | - * |
|
104 | - * {@inheritdoc} |
|
105 | - */ |
|
106 | - public function show($id, $testOnly = true) { |
|
107 | - return parent::show($id, $testOnly); |
|
108 | - } |
|
109 | - |
|
110 | - /** |
|
111 | - * Create an external storage entry. |
|
112 | - * |
|
113 | - * @param string $mountPoint storage mount point |
|
114 | - * @param string $backend backend identifier |
|
115 | - * @param string $authMechanism authentication mechanism identifier |
|
116 | - * @param array $backendOptions backend-specific options |
|
117 | - * @param array $mountOptions backend-specific mount options |
|
118 | - * |
|
119 | - * @return DataResponse |
|
120 | - * |
|
121 | - * @NoAdminRequired |
|
122 | - */ |
|
123 | - public function create( |
|
124 | - $mountPoint, |
|
125 | - $backend, |
|
126 | - $authMechanism, |
|
127 | - $backendOptions, |
|
128 | - $mountOptions |
|
129 | - ) { |
|
130 | - $newStorage = $this->createStorage( |
|
131 | - $mountPoint, |
|
132 | - $backend, |
|
133 | - $authMechanism, |
|
134 | - $backendOptions, |
|
135 | - $mountOptions |
|
136 | - ); |
|
137 | - if ($newStorage instanceOf DataResponse) { |
|
138 | - return $newStorage; |
|
139 | - } |
|
140 | - |
|
141 | - $response = $this->validate($newStorage); |
|
142 | - if (!empty($response)) { |
|
143 | - return $response; |
|
144 | - } |
|
145 | - |
|
146 | - $newStorage = $this->service->addStorage($newStorage); |
|
147 | - $this->updateStorageStatus($newStorage); |
|
148 | - |
|
149 | - return new DataResponse( |
|
150 | - $newStorage, |
|
151 | - Http::STATUS_CREATED |
|
152 | - ); |
|
153 | - } |
|
154 | - |
|
155 | - /** |
|
156 | - * Update an external storage entry. |
|
157 | - * |
|
158 | - * @param int $id storage id |
|
159 | - * @param string $mountPoint storage mount point |
|
160 | - * @param string $backend backend identifier |
|
161 | - * @param string $authMechanism authentication mechanism identifier |
|
162 | - * @param array $backendOptions backend-specific options |
|
163 | - * @param array $mountOptions backend-specific mount options |
|
164 | - * @param bool $testOnly whether to storage should only test the connection or do more things |
|
165 | - * |
|
166 | - * @return DataResponse |
|
167 | - * |
|
168 | - * @NoAdminRequired |
|
169 | - */ |
|
170 | - public function update( |
|
171 | - $id, |
|
172 | - $mountPoint, |
|
173 | - $backend, |
|
174 | - $authMechanism, |
|
175 | - $backendOptions, |
|
176 | - $mountOptions, |
|
177 | - $testOnly = true |
|
178 | - ) { |
|
179 | - $storage = $this->createStorage( |
|
180 | - $mountPoint, |
|
181 | - $backend, |
|
182 | - $authMechanism, |
|
183 | - $backendOptions, |
|
184 | - $mountOptions |
|
185 | - ); |
|
186 | - if ($storage instanceOf DataResponse) { |
|
187 | - return $storage; |
|
188 | - } |
|
189 | - $storage->setId($id); |
|
190 | - |
|
191 | - $response = $this->validate($storage); |
|
192 | - if (!empty($response)) { |
|
193 | - return $response; |
|
194 | - } |
|
195 | - |
|
196 | - try { |
|
197 | - $storage = $this->service->updateStorage($storage); |
|
198 | - } catch (NotFoundException $e) { |
|
199 | - return new DataResponse( |
|
200 | - [ |
|
201 | - 'message' => (string)$this->l10n->t('Storage with ID "%d" not found', array($id)) |
|
202 | - ], |
|
203 | - Http::STATUS_NOT_FOUND |
|
204 | - ); |
|
205 | - } |
|
206 | - |
|
207 | - $this->updateStorageStatus($storage, $testOnly); |
|
208 | - |
|
209 | - return new DataResponse( |
|
210 | - $storage, |
|
211 | - Http::STATUS_OK |
|
212 | - ); |
|
213 | - |
|
214 | - } |
|
215 | - |
|
216 | - /** |
|
217 | - * Delete storage |
|
218 | - * |
|
219 | - * @NoAdminRequired |
|
220 | - * |
|
221 | - * {@inheritdoc} |
|
222 | - */ |
|
223 | - public function destroy($id) { |
|
224 | - return parent::destroy($id); |
|
225 | - } |
|
46 | + /** |
|
47 | + * @var IUserSession |
|
48 | + */ |
|
49 | + private $userSession; |
|
50 | + |
|
51 | + /** |
|
52 | + * Creates a new user storages controller. |
|
53 | + * |
|
54 | + * @param string $AppName application name |
|
55 | + * @param IRequest $request request object |
|
56 | + * @param IL10N $l10n l10n service |
|
57 | + * @param UserStoragesService $userStoragesService storage service |
|
58 | + * @param IUserSession $userSession |
|
59 | + * @param ILogger $logger |
|
60 | + */ |
|
61 | + public function __construct( |
|
62 | + $AppName, |
|
63 | + IRequest $request, |
|
64 | + IL10N $l10n, |
|
65 | + UserStoragesService $userStoragesService, |
|
66 | + IUserSession $userSession, |
|
67 | + ILogger $logger |
|
68 | + ) { |
|
69 | + parent::__construct( |
|
70 | + $AppName, |
|
71 | + $request, |
|
72 | + $l10n, |
|
73 | + $userStoragesService, |
|
74 | + $logger |
|
75 | + ); |
|
76 | + $this->userSession = $userSession; |
|
77 | + } |
|
78 | + |
|
79 | + protected function manipulateStorageConfig(StorageConfig $storage) { |
|
80 | + /** @var AuthMechanism */ |
|
81 | + $authMechanism = $storage->getAuthMechanism(); |
|
82 | + $authMechanism->manipulateStorageConfig($storage, $this->userSession->getUser()); |
|
83 | + /** @var Backend */ |
|
84 | + $backend = $storage->getBackend(); |
|
85 | + $backend->manipulateStorageConfig($storage, $this->userSession->getUser()); |
|
86 | + } |
|
87 | + |
|
88 | + /** |
|
89 | + * Get all storage entries |
|
90 | + * |
|
91 | + * @NoAdminRequired |
|
92 | + * |
|
93 | + * @return DataResponse |
|
94 | + */ |
|
95 | + public function index() { |
|
96 | + return parent::index(); |
|
97 | + } |
|
98 | + |
|
99 | + /** |
|
100 | + * Return storage |
|
101 | + * |
|
102 | + * @NoAdminRequired |
|
103 | + * |
|
104 | + * {@inheritdoc} |
|
105 | + */ |
|
106 | + public function show($id, $testOnly = true) { |
|
107 | + return parent::show($id, $testOnly); |
|
108 | + } |
|
109 | + |
|
110 | + /** |
|
111 | + * Create an external storage entry. |
|
112 | + * |
|
113 | + * @param string $mountPoint storage mount point |
|
114 | + * @param string $backend backend identifier |
|
115 | + * @param string $authMechanism authentication mechanism identifier |
|
116 | + * @param array $backendOptions backend-specific options |
|
117 | + * @param array $mountOptions backend-specific mount options |
|
118 | + * |
|
119 | + * @return DataResponse |
|
120 | + * |
|
121 | + * @NoAdminRequired |
|
122 | + */ |
|
123 | + public function create( |
|
124 | + $mountPoint, |
|
125 | + $backend, |
|
126 | + $authMechanism, |
|
127 | + $backendOptions, |
|
128 | + $mountOptions |
|
129 | + ) { |
|
130 | + $newStorage = $this->createStorage( |
|
131 | + $mountPoint, |
|
132 | + $backend, |
|
133 | + $authMechanism, |
|
134 | + $backendOptions, |
|
135 | + $mountOptions |
|
136 | + ); |
|
137 | + if ($newStorage instanceOf DataResponse) { |
|
138 | + return $newStorage; |
|
139 | + } |
|
140 | + |
|
141 | + $response = $this->validate($newStorage); |
|
142 | + if (!empty($response)) { |
|
143 | + return $response; |
|
144 | + } |
|
145 | + |
|
146 | + $newStorage = $this->service->addStorage($newStorage); |
|
147 | + $this->updateStorageStatus($newStorage); |
|
148 | + |
|
149 | + return new DataResponse( |
|
150 | + $newStorage, |
|
151 | + Http::STATUS_CREATED |
|
152 | + ); |
|
153 | + } |
|
154 | + |
|
155 | + /** |
|
156 | + * Update an external storage entry. |
|
157 | + * |
|
158 | + * @param int $id storage id |
|
159 | + * @param string $mountPoint storage mount point |
|
160 | + * @param string $backend backend identifier |
|
161 | + * @param string $authMechanism authentication mechanism identifier |
|
162 | + * @param array $backendOptions backend-specific options |
|
163 | + * @param array $mountOptions backend-specific mount options |
|
164 | + * @param bool $testOnly whether to storage should only test the connection or do more things |
|
165 | + * |
|
166 | + * @return DataResponse |
|
167 | + * |
|
168 | + * @NoAdminRequired |
|
169 | + */ |
|
170 | + public function update( |
|
171 | + $id, |
|
172 | + $mountPoint, |
|
173 | + $backend, |
|
174 | + $authMechanism, |
|
175 | + $backendOptions, |
|
176 | + $mountOptions, |
|
177 | + $testOnly = true |
|
178 | + ) { |
|
179 | + $storage = $this->createStorage( |
|
180 | + $mountPoint, |
|
181 | + $backend, |
|
182 | + $authMechanism, |
|
183 | + $backendOptions, |
|
184 | + $mountOptions |
|
185 | + ); |
|
186 | + if ($storage instanceOf DataResponse) { |
|
187 | + return $storage; |
|
188 | + } |
|
189 | + $storage->setId($id); |
|
190 | + |
|
191 | + $response = $this->validate($storage); |
|
192 | + if (!empty($response)) { |
|
193 | + return $response; |
|
194 | + } |
|
195 | + |
|
196 | + try { |
|
197 | + $storage = $this->service->updateStorage($storage); |
|
198 | + } catch (NotFoundException $e) { |
|
199 | + return new DataResponse( |
|
200 | + [ |
|
201 | + 'message' => (string)$this->l10n->t('Storage with ID "%d" not found', array($id)) |
|
202 | + ], |
|
203 | + Http::STATUS_NOT_FOUND |
|
204 | + ); |
|
205 | + } |
|
206 | + |
|
207 | + $this->updateStorageStatus($storage, $testOnly); |
|
208 | + |
|
209 | + return new DataResponse( |
|
210 | + $storage, |
|
211 | + Http::STATUS_OK |
|
212 | + ); |
|
213 | + |
|
214 | + } |
|
215 | + |
|
216 | + /** |
|
217 | + * Delete storage |
|
218 | + * |
|
219 | + * @NoAdminRequired |
|
220 | + * |
|
221 | + * {@inheritdoc} |
|
222 | + */ |
|
223 | + public function destroy($id) { |
|
224 | + return parent::destroy($id); |
|
225 | + } |
|
226 | 226 | |
227 | 227 | } |
@@ -198,7 +198,7 @@ |
||
198 | 198 | } catch (NotFoundException $e) { |
199 | 199 | return new DataResponse( |
200 | 200 | [ |
201 | - 'message' => (string)$this->l10n->t('Storage with ID "%d" not found', array($id)) |
|
201 | + 'message' => (string) $this->l10n->t('Storage with ID "%d" not found', array($id)) |
|
202 | 202 | ], |
203 | 203 | Http::STATUS_NOT_FOUND |
204 | 204 | ); |
@@ -39,151 +39,151 @@ |
||
39 | 39 | * Global storages controller |
40 | 40 | */ |
41 | 41 | class GlobalStoragesController extends StoragesController { |
42 | - /** |
|
43 | - * Creates a new global storages controller. |
|
44 | - * |
|
45 | - * @param string $AppName application name |
|
46 | - * @param IRequest $request request object |
|
47 | - * @param IL10N $l10n l10n service |
|
48 | - * @param GlobalStoragesService $globalStoragesService storage service |
|
49 | - * @param ILogger $logger |
|
50 | - */ |
|
51 | - public function __construct( |
|
52 | - $AppName, |
|
53 | - IRequest $request, |
|
54 | - IL10N $l10n, |
|
55 | - GlobalStoragesService $globalStoragesService, |
|
56 | - ILogger $logger |
|
57 | - ) { |
|
58 | - parent::__construct( |
|
59 | - $AppName, |
|
60 | - $request, |
|
61 | - $l10n, |
|
62 | - $globalStoragesService, |
|
63 | - $logger |
|
64 | - ); |
|
65 | - } |
|
66 | - |
|
67 | - /** |
|
68 | - * Create an external storage entry. |
|
69 | - * |
|
70 | - * @param string $mountPoint storage mount point |
|
71 | - * @param string $backend backend identifier |
|
72 | - * @param string $authMechanism authentication mechanism identifier |
|
73 | - * @param array $backendOptions backend-specific options |
|
74 | - * @param array $mountOptions mount-specific options |
|
75 | - * @param array $applicableUsers users for which to mount the storage |
|
76 | - * @param array $applicableGroups groups for which to mount the storage |
|
77 | - * @param int $priority priority |
|
78 | - * |
|
79 | - * @return DataResponse |
|
80 | - */ |
|
81 | - public function create( |
|
82 | - $mountPoint, |
|
83 | - $backend, |
|
84 | - $authMechanism, |
|
85 | - $backendOptions, |
|
86 | - $mountOptions, |
|
87 | - $applicableUsers, |
|
88 | - $applicableGroups, |
|
89 | - $priority |
|
90 | - ) { |
|
91 | - $newStorage = $this->createStorage( |
|
92 | - $mountPoint, |
|
93 | - $backend, |
|
94 | - $authMechanism, |
|
95 | - $backendOptions, |
|
96 | - $mountOptions, |
|
97 | - $applicableUsers, |
|
98 | - $applicableGroups, |
|
99 | - $priority |
|
100 | - ); |
|
101 | - if ($newStorage instanceof DataResponse) { |
|
102 | - return $newStorage; |
|
103 | - } |
|
104 | - |
|
105 | - $response = $this->validate($newStorage); |
|
106 | - if (!empty($response)) { |
|
107 | - return $response; |
|
108 | - } |
|
109 | - |
|
110 | - $newStorage = $this->service->addStorage($newStorage); |
|
111 | - |
|
112 | - $this->updateStorageStatus($newStorage); |
|
113 | - |
|
114 | - return new DataResponse( |
|
115 | - $newStorage, |
|
116 | - Http::STATUS_CREATED |
|
117 | - ); |
|
118 | - } |
|
119 | - |
|
120 | - /** |
|
121 | - * Update an external storage entry. |
|
122 | - * |
|
123 | - * @param int $id storage id |
|
124 | - * @param string $mountPoint storage mount point |
|
125 | - * @param string $backend backend identifier |
|
126 | - * @param string $authMechanism authentication mechansim identifier |
|
127 | - * @param array $backendOptions backend-specific options |
|
128 | - * @param array $mountOptions mount-specific options |
|
129 | - * @param array $applicableUsers users for which to mount the storage |
|
130 | - * @param array $applicableGroups groups for which to mount the storage |
|
131 | - * @param int $priority priority |
|
132 | - * @param bool $testOnly whether to storage should only test the connection or do more things |
|
133 | - * |
|
134 | - * @return DataResponse |
|
135 | - */ |
|
136 | - public function update( |
|
137 | - $id, |
|
138 | - $mountPoint, |
|
139 | - $backend, |
|
140 | - $authMechanism, |
|
141 | - $backendOptions, |
|
142 | - $mountOptions, |
|
143 | - $applicableUsers, |
|
144 | - $applicableGroups, |
|
145 | - $priority, |
|
146 | - $testOnly = true |
|
147 | - ) { |
|
148 | - $storage = $this->createStorage( |
|
149 | - $mountPoint, |
|
150 | - $backend, |
|
151 | - $authMechanism, |
|
152 | - $backendOptions, |
|
153 | - $mountOptions, |
|
154 | - $applicableUsers, |
|
155 | - $applicableGroups, |
|
156 | - $priority |
|
157 | - ); |
|
158 | - if ($storage instanceof DataResponse) { |
|
159 | - return $storage; |
|
160 | - } |
|
161 | - $storage->setId($id); |
|
162 | - |
|
163 | - $response = $this->validate($storage); |
|
164 | - if (!empty($response)) { |
|
165 | - return $response; |
|
166 | - } |
|
167 | - |
|
168 | - try { |
|
169 | - $storage = $this->service->updateStorage($storage); |
|
170 | - } catch (NotFoundException $e) { |
|
171 | - return new DataResponse( |
|
172 | - [ |
|
173 | - 'message' => (string)$this->l10n->t('Storage with ID "%d" not found', array($id)) |
|
174 | - ], |
|
175 | - Http::STATUS_NOT_FOUND |
|
176 | - ); |
|
177 | - } |
|
178 | - |
|
179 | - $this->updateStorageStatus($storage, $testOnly); |
|
180 | - |
|
181 | - return new DataResponse( |
|
182 | - $storage, |
|
183 | - Http::STATUS_OK |
|
184 | - ); |
|
185 | - |
|
186 | - } |
|
42 | + /** |
|
43 | + * Creates a new global storages controller. |
|
44 | + * |
|
45 | + * @param string $AppName application name |
|
46 | + * @param IRequest $request request object |
|
47 | + * @param IL10N $l10n l10n service |
|
48 | + * @param GlobalStoragesService $globalStoragesService storage service |
|
49 | + * @param ILogger $logger |
|
50 | + */ |
|
51 | + public function __construct( |
|
52 | + $AppName, |
|
53 | + IRequest $request, |
|
54 | + IL10N $l10n, |
|
55 | + GlobalStoragesService $globalStoragesService, |
|
56 | + ILogger $logger |
|
57 | + ) { |
|
58 | + parent::__construct( |
|
59 | + $AppName, |
|
60 | + $request, |
|
61 | + $l10n, |
|
62 | + $globalStoragesService, |
|
63 | + $logger |
|
64 | + ); |
|
65 | + } |
|
66 | + |
|
67 | + /** |
|
68 | + * Create an external storage entry. |
|
69 | + * |
|
70 | + * @param string $mountPoint storage mount point |
|
71 | + * @param string $backend backend identifier |
|
72 | + * @param string $authMechanism authentication mechanism identifier |
|
73 | + * @param array $backendOptions backend-specific options |
|
74 | + * @param array $mountOptions mount-specific options |
|
75 | + * @param array $applicableUsers users for which to mount the storage |
|
76 | + * @param array $applicableGroups groups for which to mount the storage |
|
77 | + * @param int $priority priority |
|
78 | + * |
|
79 | + * @return DataResponse |
|
80 | + */ |
|
81 | + public function create( |
|
82 | + $mountPoint, |
|
83 | + $backend, |
|
84 | + $authMechanism, |
|
85 | + $backendOptions, |
|
86 | + $mountOptions, |
|
87 | + $applicableUsers, |
|
88 | + $applicableGroups, |
|
89 | + $priority |
|
90 | + ) { |
|
91 | + $newStorage = $this->createStorage( |
|
92 | + $mountPoint, |
|
93 | + $backend, |
|
94 | + $authMechanism, |
|
95 | + $backendOptions, |
|
96 | + $mountOptions, |
|
97 | + $applicableUsers, |
|
98 | + $applicableGroups, |
|
99 | + $priority |
|
100 | + ); |
|
101 | + if ($newStorage instanceof DataResponse) { |
|
102 | + return $newStorage; |
|
103 | + } |
|
104 | + |
|
105 | + $response = $this->validate($newStorage); |
|
106 | + if (!empty($response)) { |
|
107 | + return $response; |
|
108 | + } |
|
109 | + |
|
110 | + $newStorage = $this->service->addStorage($newStorage); |
|
111 | + |
|
112 | + $this->updateStorageStatus($newStorage); |
|
113 | + |
|
114 | + return new DataResponse( |
|
115 | + $newStorage, |
|
116 | + Http::STATUS_CREATED |
|
117 | + ); |
|
118 | + } |
|
119 | + |
|
120 | + /** |
|
121 | + * Update an external storage entry. |
|
122 | + * |
|
123 | + * @param int $id storage id |
|
124 | + * @param string $mountPoint storage mount point |
|
125 | + * @param string $backend backend identifier |
|
126 | + * @param string $authMechanism authentication mechansim identifier |
|
127 | + * @param array $backendOptions backend-specific options |
|
128 | + * @param array $mountOptions mount-specific options |
|
129 | + * @param array $applicableUsers users for which to mount the storage |
|
130 | + * @param array $applicableGroups groups for which to mount the storage |
|
131 | + * @param int $priority priority |
|
132 | + * @param bool $testOnly whether to storage should only test the connection or do more things |
|
133 | + * |
|
134 | + * @return DataResponse |
|
135 | + */ |
|
136 | + public function update( |
|
137 | + $id, |
|
138 | + $mountPoint, |
|
139 | + $backend, |
|
140 | + $authMechanism, |
|
141 | + $backendOptions, |
|
142 | + $mountOptions, |
|
143 | + $applicableUsers, |
|
144 | + $applicableGroups, |
|
145 | + $priority, |
|
146 | + $testOnly = true |
|
147 | + ) { |
|
148 | + $storage = $this->createStorage( |
|
149 | + $mountPoint, |
|
150 | + $backend, |
|
151 | + $authMechanism, |
|
152 | + $backendOptions, |
|
153 | + $mountOptions, |
|
154 | + $applicableUsers, |
|
155 | + $applicableGroups, |
|
156 | + $priority |
|
157 | + ); |
|
158 | + if ($storage instanceof DataResponse) { |
|
159 | + return $storage; |
|
160 | + } |
|
161 | + $storage->setId($id); |
|
162 | + |
|
163 | + $response = $this->validate($storage); |
|
164 | + if (!empty($response)) { |
|
165 | + return $response; |
|
166 | + } |
|
167 | + |
|
168 | + try { |
|
169 | + $storage = $this->service->updateStorage($storage); |
|
170 | + } catch (NotFoundException $e) { |
|
171 | + return new DataResponse( |
|
172 | + [ |
|
173 | + 'message' => (string)$this->l10n->t('Storage with ID "%d" not found', array($id)) |
|
174 | + ], |
|
175 | + Http::STATUS_NOT_FOUND |
|
176 | + ); |
|
177 | + } |
|
178 | + |
|
179 | + $this->updateStorageStatus($storage, $testOnly); |
|
180 | + |
|
181 | + return new DataResponse( |
|
182 | + $storage, |
|
183 | + Http::STATUS_OK |
|
184 | + ); |
|
185 | + |
|
186 | + } |
|
187 | 187 | |
188 | 188 | |
189 | 189 | } |
@@ -198,7 +198,7 @@ |
||
198 | 198 | } catch (NotFoundException $e) { |
199 | 199 | return new DataResponse( |
200 | 200 | [ |
201 | - 'message' => (string)$this->l10n->t('Storage with ID "%d" not found', array($id)) |
|
201 | + 'message' => (string) $this->l10n->t('Storage with ID "%d" not found', array($id)) |
|
202 | 202 | ], |
203 | 203 | Http::STATUS_NOT_FOUND |
204 | 204 | ); |
@@ -47,298 +47,298 @@ |
||
47 | 47 | */ |
48 | 48 | abstract class StoragesController extends Controller { |
49 | 49 | |
50 | - /** |
|
51 | - * L10N service |
|
52 | - * |
|
53 | - * @var IL10N |
|
54 | - */ |
|
55 | - protected $l10n; |
|
50 | + /** |
|
51 | + * L10N service |
|
52 | + * |
|
53 | + * @var IL10N |
|
54 | + */ |
|
55 | + protected $l10n; |
|
56 | 56 | |
57 | - /** |
|
58 | - * Storages service |
|
59 | - * |
|
60 | - * @var StoragesService |
|
61 | - */ |
|
62 | - protected $service; |
|
57 | + /** |
|
58 | + * Storages service |
|
59 | + * |
|
60 | + * @var StoragesService |
|
61 | + */ |
|
62 | + protected $service; |
|
63 | 63 | |
64 | - /** |
|
65 | - * @var ILogger |
|
66 | - */ |
|
67 | - protected $logger; |
|
64 | + /** |
|
65 | + * @var ILogger |
|
66 | + */ |
|
67 | + protected $logger; |
|
68 | 68 | |
69 | - /** |
|
70 | - * Creates a new storages controller. |
|
71 | - * |
|
72 | - * @param string $AppName application name |
|
73 | - * @param IRequest $request request object |
|
74 | - * @param IL10N $l10n l10n service |
|
75 | - * @param StoragesService $storagesService storage service |
|
76 | - * @param ILogger $logger |
|
77 | - */ |
|
78 | - public function __construct( |
|
79 | - $AppName, |
|
80 | - IRequest $request, |
|
81 | - IL10N $l10n, |
|
82 | - StoragesService $storagesService, |
|
83 | - ILogger $logger |
|
84 | - ) { |
|
85 | - parent::__construct($AppName, $request); |
|
86 | - $this->l10n = $l10n; |
|
87 | - $this->service = $storagesService; |
|
88 | - $this->logger = $logger; |
|
89 | - } |
|
69 | + /** |
|
70 | + * Creates a new storages controller. |
|
71 | + * |
|
72 | + * @param string $AppName application name |
|
73 | + * @param IRequest $request request object |
|
74 | + * @param IL10N $l10n l10n service |
|
75 | + * @param StoragesService $storagesService storage service |
|
76 | + * @param ILogger $logger |
|
77 | + */ |
|
78 | + public function __construct( |
|
79 | + $AppName, |
|
80 | + IRequest $request, |
|
81 | + IL10N $l10n, |
|
82 | + StoragesService $storagesService, |
|
83 | + ILogger $logger |
|
84 | + ) { |
|
85 | + parent::__construct($AppName, $request); |
|
86 | + $this->l10n = $l10n; |
|
87 | + $this->service = $storagesService; |
|
88 | + $this->logger = $logger; |
|
89 | + } |
|
90 | 90 | |
91 | - /** |
|
92 | - * Create a storage from its parameters |
|
93 | - * |
|
94 | - * @param string $mountPoint storage mount point |
|
95 | - * @param string $backend backend identifier |
|
96 | - * @param string $authMechanism authentication mechanism identifier |
|
97 | - * @param array $backendOptions backend-specific options |
|
98 | - * @param array|null $mountOptions mount-specific options |
|
99 | - * @param array|null $applicableUsers users for which to mount the storage |
|
100 | - * @param array|null $applicableGroups groups for which to mount the storage |
|
101 | - * @param int|null $priority priority |
|
102 | - * |
|
103 | - * @return StorageConfig|DataResponse |
|
104 | - */ |
|
105 | - protected function createStorage( |
|
106 | - $mountPoint, |
|
107 | - $backend, |
|
108 | - $authMechanism, |
|
109 | - $backendOptions, |
|
110 | - $mountOptions = null, |
|
111 | - $applicableUsers = null, |
|
112 | - $applicableGroups = null, |
|
113 | - $priority = null |
|
114 | - ) { |
|
115 | - try { |
|
116 | - return $this->service->createStorage( |
|
117 | - $mountPoint, |
|
118 | - $backend, |
|
119 | - $authMechanism, |
|
120 | - $backendOptions, |
|
121 | - $mountOptions, |
|
122 | - $applicableUsers, |
|
123 | - $applicableGroups, |
|
124 | - $priority |
|
125 | - ); |
|
126 | - } catch (\InvalidArgumentException $e) { |
|
127 | - $this->logger->logException($e); |
|
128 | - return new DataResponse( |
|
129 | - [ |
|
130 | - 'message' => (string)$this->l10n->t('Invalid backend or authentication mechanism class') |
|
131 | - ], |
|
132 | - Http::STATUS_UNPROCESSABLE_ENTITY |
|
133 | - ); |
|
134 | - } |
|
135 | - } |
|
91 | + /** |
|
92 | + * Create a storage from its parameters |
|
93 | + * |
|
94 | + * @param string $mountPoint storage mount point |
|
95 | + * @param string $backend backend identifier |
|
96 | + * @param string $authMechanism authentication mechanism identifier |
|
97 | + * @param array $backendOptions backend-specific options |
|
98 | + * @param array|null $mountOptions mount-specific options |
|
99 | + * @param array|null $applicableUsers users for which to mount the storage |
|
100 | + * @param array|null $applicableGroups groups for which to mount the storage |
|
101 | + * @param int|null $priority priority |
|
102 | + * |
|
103 | + * @return StorageConfig|DataResponse |
|
104 | + */ |
|
105 | + protected function createStorage( |
|
106 | + $mountPoint, |
|
107 | + $backend, |
|
108 | + $authMechanism, |
|
109 | + $backendOptions, |
|
110 | + $mountOptions = null, |
|
111 | + $applicableUsers = null, |
|
112 | + $applicableGroups = null, |
|
113 | + $priority = null |
|
114 | + ) { |
|
115 | + try { |
|
116 | + return $this->service->createStorage( |
|
117 | + $mountPoint, |
|
118 | + $backend, |
|
119 | + $authMechanism, |
|
120 | + $backendOptions, |
|
121 | + $mountOptions, |
|
122 | + $applicableUsers, |
|
123 | + $applicableGroups, |
|
124 | + $priority |
|
125 | + ); |
|
126 | + } catch (\InvalidArgumentException $e) { |
|
127 | + $this->logger->logException($e); |
|
128 | + return new DataResponse( |
|
129 | + [ |
|
130 | + 'message' => (string)$this->l10n->t('Invalid backend or authentication mechanism class') |
|
131 | + ], |
|
132 | + Http::STATUS_UNPROCESSABLE_ENTITY |
|
133 | + ); |
|
134 | + } |
|
135 | + } |
|
136 | 136 | |
137 | - /** |
|
138 | - * Validate storage config |
|
139 | - * |
|
140 | - * @param StorageConfig $storage storage config |
|
141 | - *1 |
|
142 | - * @return DataResponse|null returns response in case of validation error |
|
143 | - */ |
|
144 | - protected function validate(StorageConfig $storage) { |
|
145 | - $mountPoint = $storage->getMountPoint(); |
|
146 | - if ($mountPoint === '') { |
|
147 | - return new DataResponse( |
|
148 | - array( |
|
149 | - 'message' => (string)$this->l10n->t('Invalid mount point') |
|
150 | - ), |
|
151 | - Http::STATUS_UNPROCESSABLE_ENTITY |
|
152 | - ); |
|
153 | - } |
|
137 | + /** |
|
138 | + * Validate storage config |
|
139 | + * |
|
140 | + * @param StorageConfig $storage storage config |
|
141 | + *1 |
|
142 | + * @return DataResponse|null returns response in case of validation error |
|
143 | + */ |
|
144 | + protected function validate(StorageConfig $storage) { |
|
145 | + $mountPoint = $storage->getMountPoint(); |
|
146 | + if ($mountPoint === '') { |
|
147 | + return new DataResponse( |
|
148 | + array( |
|
149 | + 'message' => (string)$this->l10n->t('Invalid mount point') |
|
150 | + ), |
|
151 | + Http::STATUS_UNPROCESSABLE_ENTITY |
|
152 | + ); |
|
153 | + } |
|
154 | 154 | |
155 | - if ($storage->getBackendOption('objectstore')) { |
|
156 | - // objectstore must not be sent from client side |
|
157 | - return new DataResponse( |
|
158 | - array( |
|
159 | - 'message' => (string)$this->l10n->t('Objectstore forbidden') |
|
160 | - ), |
|
161 | - Http::STATUS_UNPROCESSABLE_ENTITY |
|
162 | - ); |
|
163 | - } |
|
155 | + if ($storage->getBackendOption('objectstore')) { |
|
156 | + // objectstore must not be sent from client side |
|
157 | + return new DataResponse( |
|
158 | + array( |
|
159 | + 'message' => (string)$this->l10n->t('Objectstore forbidden') |
|
160 | + ), |
|
161 | + Http::STATUS_UNPROCESSABLE_ENTITY |
|
162 | + ); |
|
163 | + } |
|
164 | 164 | |
165 | - /** @var Backend */ |
|
166 | - $backend = $storage->getBackend(); |
|
167 | - /** @var AuthMechanism */ |
|
168 | - $authMechanism = $storage->getAuthMechanism(); |
|
169 | - if ($backend->checkDependencies()) { |
|
170 | - // invalid backend |
|
171 | - return new DataResponse( |
|
172 | - array( |
|
173 | - 'message' => (string)$this->l10n->t('Invalid storage backend "%s"', [ |
|
174 | - $backend->getIdentifier() |
|
175 | - ]) |
|
176 | - ), |
|
177 | - Http::STATUS_UNPROCESSABLE_ENTITY |
|
178 | - ); |
|
179 | - } |
|
165 | + /** @var Backend */ |
|
166 | + $backend = $storage->getBackend(); |
|
167 | + /** @var AuthMechanism */ |
|
168 | + $authMechanism = $storage->getAuthMechanism(); |
|
169 | + if ($backend->checkDependencies()) { |
|
170 | + // invalid backend |
|
171 | + return new DataResponse( |
|
172 | + array( |
|
173 | + 'message' => (string)$this->l10n->t('Invalid storage backend "%s"', [ |
|
174 | + $backend->getIdentifier() |
|
175 | + ]) |
|
176 | + ), |
|
177 | + Http::STATUS_UNPROCESSABLE_ENTITY |
|
178 | + ); |
|
179 | + } |
|
180 | 180 | |
181 | - if (!$backend->isVisibleFor($this->service->getVisibilityType())) { |
|
182 | - // not permitted to use backend |
|
183 | - return new DataResponse( |
|
184 | - array( |
|
185 | - 'message' => (string)$this->l10n->t('Not permitted to use backend "%s"', [ |
|
186 | - $backend->getIdentifier() |
|
187 | - ]) |
|
188 | - ), |
|
189 | - Http::STATUS_UNPROCESSABLE_ENTITY |
|
190 | - ); |
|
191 | - } |
|
192 | - if (!$authMechanism->isVisibleFor($this->service->getVisibilityType())) { |
|
193 | - // not permitted to use auth mechanism |
|
194 | - return new DataResponse( |
|
195 | - array( |
|
196 | - 'message' => (string)$this->l10n->t('Not permitted to use authentication mechanism "%s"', [ |
|
197 | - $authMechanism->getIdentifier() |
|
198 | - ]) |
|
199 | - ), |
|
200 | - Http::STATUS_UNPROCESSABLE_ENTITY |
|
201 | - ); |
|
202 | - } |
|
181 | + if (!$backend->isVisibleFor($this->service->getVisibilityType())) { |
|
182 | + // not permitted to use backend |
|
183 | + return new DataResponse( |
|
184 | + array( |
|
185 | + 'message' => (string)$this->l10n->t('Not permitted to use backend "%s"', [ |
|
186 | + $backend->getIdentifier() |
|
187 | + ]) |
|
188 | + ), |
|
189 | + Http::STATUS_UNPROCESSABLE_ENTITY |
|
190 | + ); |
|
191 | + } |
|
192 | + if (!$authMechanism->isVisibleFor($this->service->getVisibilityType())) { |
|
193 | + // not permitted to use auth mechanism |
|
194 | + return new DataResponse( |
|
195 | + array( |
|
196 | + 'message' => (string)$this->l10n->t('Not permitted to use authentication mechanism "%s"', [ |
|
197 | + $authMechanism->getIdentifier() |
|
198 | + ]) |
|
199 | + ), |
|
200 | + Http::STATUS_UNPROCESSABLE_ENTITY |
|
201 | + ); |
|
202 | + } |
|
203 | 203 | |
204 | - if (!$backend->validateStorage($storage)) { |
|
205 | - // unsatisfied parameters |
|
206 | - return new DataResponse( |
|
207 | - array( |
|
208 | - 'message' => (string)$this->l10n->t('Unsatisfied backend parameters') |
|
209 | - ), |
|
210 | - Http::STATUS_UNPROCESSABLE_ENTITY |
|
211 | - ); |
|
212 | - } |
|
213 | - if (!$authMechanism->validateStorage($storage)) { |
|
214 | - // unsatisfied parameters |
|
215 | - return new DataResponse( |
|
216 | - [ |
|
217 | - 'message' => (string)$this->l10n->t('Unsatisfied authentication mechanism parameters') |
|
218 | - ], |
|
219 | - Http::STATUS_UNPROCESSABLE_ENTITY |
|
220 | - ); |
|
221 | - } |
|
204 | + if (!$backend->validateStorage($storage)) { |
|
205 | + // unsatisfied parameters |
|
206 | + return new DataResponse( |
|
207 | + array( |
|
208 | + 'message' => (string)$this->l10n->t('Unsatisfied backend parameters') |
|
209 | + ), |
|
210 | + Http::STATUS_UNPROCESSABLE_ENTITY |
|
211 | + ); |
|
212 | + } |
|
213 | + if (!$authMechanism->validateStorage($storage)) { |
|
214 | + // unsatisfied parameters |
|
215 | + return new DataResponse( |
|
216 | + [ |
|
217 | + 'message' => (string)$this->l10n->t('Unsatisfied authentication mechanism parameters') |
|
218 | + ], |
|
219 | + Http::STATUS_UNPROCESSABLE_ENTITY |
|
220 | + ); |
|
221 | + } |
|
222 | 222 | |
223 | - return null; |
|
224 | - } |
|
223 | + return null; |
|
224 | + } |
|
225 | 225 | |
226 | - protected function manipulateStorageConfig(StorageConfig $storage) { |
|
227 | - /** @var AuthMechanism */ |
|
228 | - $authMechanism = $storage->getAuthMechanism(); |
|
229 | - $authMechanism->manipulateStorageConfig($storage); |
|
230 | - /** @var Backend */ |
|
231 | - $backend = $storage->getBackend(); |
|
232 | - $backend->manipulateStorageConfig($storage); |
|
233 | - } |
|
226 | + protected function manipulateStorageConfig(StorageConfig $storage) { |
|
227 | + /** @var AuthMechanism */ |
|
228 | + $authMechanism = $storage->getAuthMechanism(); |
|
229 | + $authMechanism->manipulateStorageConfig($storage); |
|
230 | + /** @var Backend */ |
|
231 | + $backend = $storage->getBackend(); |
|
232 | + $backend->manipulateStorageConfig($storage); |
|
233 | + } |
|
234 | 234 | |
235 | - /** |
|
236 | - * Check whether the given storage is available / valid. |
|
237 | - * |
|
238 | - * Note that this operation can be time consuming depending |
|
239 | - * on whether the remote storage is available or not. |
|
240 | - * |
|
241 | - * @param StorageConfig $storage storage configuration |
|
242 | - * @param bool $testOnly whether to storage should only test the connection or do more things |
|
243 | - */ |
|
244 | - protected function updateStorageStatus(StorageConfig &$storage, $testOnly = true) { |
|
245 | - try { |
|
246 | - $this->manipulateStorageConfig($storage); |
|
235 | + /** |
|
236 | + * Check whether the given storage is available / valid. |
|
237 | + * |
|
238 | + * Note that this operation can be time consuming depending |
|
239 | + * on whether the remote storage is available or not. |
|
240 | + * |
|
241 | + * @param StorageConfig $storage storage configuration |
|
242 | + * @param bool $testOnly whether to storage should only test the connection or do more things |
|
243 | + */ |
|
244 | + protected function updateStorageStatus(StorageConfig &$storage, $testOnly = true) { |
|
245 | + try { |
|
246 | + $this->manipulateStorageConfig($storage); |
|
247 | 247 | |
248 | - /** @var Backend */ |
|
249 | - $backend = $storage->getBackend(); |
|
250 | - // update status (can be time-consuming) |
|
251 | - $storage->setStatus( |
|
252 | - \OC_Mount_Config::getBackendStatus( |
|
253 | - $backend->getStorageClass(), |
|
254 | - $storage->getBackendOptions(), |
|
255 | - false, |
|
256 | - $testOnly |
|
257 | - ) |
|
258 | - ); |
|
259 | - } catch (InsufficientDataForMeaningfulAnswerException $e) { |
|
260 | - $status = $e->getCode() ? $e->getCode() : StorageNotAvailableException::STATUS_INDETERMINATE; |
|
261 | - $storage->setStatus( |
|
262 | - $status, |
|
263 | - $this->l10n->t('Insufficient data: %s', [$e->getMessage()]) |
|
264 | - ); |
|
265 | - } catch (StorageNotAvailableException $e) { |
|
266 | - $storage->setStatus( |
|
267 | - $e->getCode(), |
|
268 | - $this->l10n->t('%s', [$e->getMessage()]) |
|
269 | - ); |
|
270 | - } catch (\Exception $e) { |
|
271 | - // FIXME: convert storage exceptions to StorageNotAvailableException |
|
272 | - $storage->setStatus( |
|
273 | - StorageNotAvailableException::STATUS_ERROR, |
|
274 | - get_class($e).': '.$e->getMessage() |
|
275 | - ); |
|
276 | - } |
|
277 | - } |
|
248 | + /** @var Backend */ |
|
249 | + $backend = $storage->getBackend(); |
|
250 | + // update status (can be time-consuming) |
|
251 | + $storage->setStatus( |
|
252 | + \OC_Mount_Config::getBackendStatus( |
|
253 | + $backend->getStorageClass(), |
|
254 | + $storage->getBackendOptions(), |
|
255 | + false, |
|
256 | + $testOnly |
|
257 | + ) |
|
258 | + ); |
|
259 | + } catch (InsufficientDataForMeaningfulAnswerException $e) { |
|
260 | + $status = $e->getCode() ? $e->getCode() : StorageNotAvailableException::STATUS_INDETERMINATE; |
|
261 | + $storage->setStatus( |
|
262 | + $status, |
|
263 | + $this->l10n->t('Insufficient data: %s', [$e->getMessage()]) |
|
264 | + ); |
|
265 | + } catch (StorageNotAvailableException $e) { |
|
266 | + $storage->setStatus( |
|
267 | + $e->getCode(), |
|
268 | + $this->l10n->t('%s', [$e->getMessage()]) |
|
269 | + ); |
|
270 | + } catch (\Exception $e) { |
|
271 | + // FIXME: convert storage exceptions to StorageNotAvailableException |
|
272 | + $storage->setStatus( |
|
273 | + StorageNotAvailableException::STATUS_ERROR, |
|
274 | + get_class($e).': '.$e->getMessage() |
|
275 | + ); |
|
276 | + } |
|
277 | + } |
|
278 | 278 | |
279 | - /** |
|
280 | - * Get all storage entries |
|
281 | - * |
|
282 | - * @return DataResponse |
|
283 | - */ |
|
284 | - public function index() { |
|
285 | - $storages = $this->service->getStorages(); |
|
279 | + /** |
|
280 | + * Get all storage entries |
|
281 | + * |
|
282 | + * @return DataResponse |
|
283 | + */ |
|
284 | + public function index() { |
|
285 | + $storages = $this->service->getStorages(); |
|
286 | 286 | |
287 | - return new DataResponse( |
|
288 | - $storages, |
|
289 | - Http::STATUS_OK |
|
290 | - ); |
|
291 | - } |
|
287 | + return new DataResponse( |
|
288 | + $storages, |
|
289 | + Http::STATUS_OK |
|
290 | + ); |
|
291 | + } |
|
292 | 292 | |
293 | - /** |
|
294 | - * Get an external storage entry. |
|
295 | - * |
|
296 | - * @param int $id storage id |
|
297 | - * @param bool $testOnly whether to storage should only test the connection or do more things |
|
298 | - * |
|
299 | - * @return DataResponse |
|
300 | - */ |
|
301 | - public function show($id, $testOnly = true) { |
|
302 | - try { |
|
303 | - $storage = $this->service->getStorage($id); |
|
293 | + /** |
|
294 | + * Get an external storage entry. |
|
295 | + * |
|
296 | + * @param int $id storage id |
|
297 | + * @param bool $testOnly whether to storage should only test the connection or do more things |
|
298 | + * |
|
299 | + * @return DataResponse |
|
300 | + */ |
|
301 | + public function show($id, $testOnly = true) { |
|
302 | + try { |
|
303 | + $storage = $this->service->getStorage($id); |
|
304 | 304 | |
305 | - $this->updateStorageStatus($storage, $testOnly); |
|
306 | - } catch (NotFoundException $e) { |
|
307 | - return new DataResponse( |
|
308 | - [ |
|
309 | - 'message' => (string)$this->l10n->t('Storage with ID "%d" not found', array($id)) |
|
310 | - ], |
|
311 | - Http::STATUS_NOT_FOUND |
|
312 | - ); |
|
313 | - } |
|
305 | + $this->updateStorageStatus($storage, $testOnly); |
|
306 | + } catch (NotFoundException $e) { |
|
307 | + return new DataResponse( |
|
308 | + [ |
|
309 | + 'message' => (string)$this->l10n->t('Storage with ID "%d" not found', array($id)) |
|
310 | + ], |
|
311 | + Http::STATUS_NOT_FOUND |
|
312 | + ); |
|
313 | + } |
|
314 | 314 | |
315 | - return new DataResponse( |
|
316 | - $storage, |
|
317 | - Http::STATUS_OK |
|
318 | - ); |
|
319 | - } |
|
315 | + return new DataResponse( |
|
316 | + $storage, |
|
317 | + Http::STATUS_OK |
|
318 | + ); |
|
319 | + } |
|
320 | 320 | |
321 | - /** |
|
322 | - * Deletes the storage with the given id. |
|
323 | - * |
|
324 | - * @param int $id storage id |
|
325 | - * |
|
326 | - * @return DataResponse |
|
327 | - */ |
|
328 | - public function destroy($id) { |
|
329 | - try { |
|
330 | - $this->service->removeStorage($id); |
|
331 | - } catch (NotFoundException $e) { |
|
332 | - return new DataResponse( |
|
333 | - [ |
|
334 | - 'message' => (string)$this->l10n->t('Storage with ID "%d" not found', array($id)) |
|
335 | - ], |
|
336 | - Http::STATUS_NOT_FOUND |
|
337 | - ); |
|
338 | - } |
|
321 | + /** |
|
322 | + * Deletes the storage with the given id. |
|
323 | + * |
|
324 | + * @param int $id storage id |
|
325 | + * |
|
326 | + * @return DataResponse |
|
327 | + */ |
|
328 | + public function destroy($id) { |
|
329 | + try { |
|
330 | + $this->service->removeStorage($id); |
|
331 | + } catch (NotFoundException $e) { |
|
332 | + return new DataResponse( |
|
333 | + [ |
|
334 | + 'message' => (string)$this->l10n->t('Storage with ID "%d" not found', array($id)) |
|
335 | + ], |
|
336 | + Http::STATUS_NOT_FOUND |
|
337 | + ); |
|
338 | + } |
|
339 | 339 | |
340 | - return new DataResponse([], Http::STATUS_NO_CONTENT); |
|
341 | - } |
|
340 | + return new DataResponse([], Http::STATUS_NO_CONTENT); |
|
341 | + } |
|
342 | 342 | |
343 | 343 | } |
344 | 344 |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | $this->logger->logException($e); |
128 | 128 | return new DataResponse( |
129 | 129 | [ |
130 | - 'message' => (string)$this->l10n->t('Invalid backend or authentication mechanism class') |
|
130 | + 'message' => (string) $this->l10n->t('Invalid backend or authentication mechanism class') |
|
131 | 131 | ], |
132 | 132 | Http::STATUS_UNPROCESSABLE_ENTITY |
133 | 133 | ); |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | if ($mountPoint === '') { |
147 | 147 | return new DataResponse( |
148 | 148 | array( |
149 | - 'message' => (string)$this->l10n->t('Invalid mount point') |
|
149 | + 'message' => (string) $this->l10n->t('Invalid mount point') |
|
150 | 150 | ), |
151 | 151 | Http::STATUS_UNPROCESSABLE_ENTITY |
152 | 152 | ); |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | // objectstore must not be sent from client side |
157 | 157 | return new DataResponse( |
158 | 158 | array( |
159 | - 'message' => (string)$this->l10n->t('Objectstore forbidden') |
|
159 | + 'message' => (string) $this->l10n->t('Objectstore forbidden') |
|
160 | 160 | ), |
161 | 161 | Http::STATUS_UNPROCESSABLE_ENTITY |
162 | 162 | ); |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | // invalid backend |
171 | 171 | return new DataResponse( |
172 | 172 | array( |
173 | - 'message' => (string)$this->l10n->t('Invalid storage backend "%s"', [ |
|
173 | + 'message' => (string) $this->l10n->t('Invalid storage backend "%s"', [ |
|
174 | 174 | $backend->getIdentifier() |
175 | 175 | ]) |
176 | 176 | ), |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | // not permitted to use backend |
183 | 183 | return new DataResponse( |
184 | 184 | array( |
185 | - 'message' => (string)$this->l10n->t('Not permitted to use backend "%s"', [ |
|
185 | + 'message' => (string) $this->l10n->t('Not permitted to use backend "%s"', [ |
|
186 | 186 | $backend->getIdentifier() |
187 | 187 | ]) |
188 | 188 | ), |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | // not permitted to use auth mechanism |
194 | 194 | return new DataResponse( |
195 | 195 | array( |
196 | - 'message' => (string)$this->l10n->t('Not permitted to use authentication mechanism "%s"', [ |
|
196 | + 'message' => (string) $this->l10n->t('Not permitted to use authentication mechanism "%s"', [ |
|
197 | 197 | $authMechanism->getIdentifier() |
198 | 198 | ]) |
199 | 199 | ), |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | // unsatisfied parameters |
206 | 206 | return new DataResponse( |
207 | 207 | array( |
208 | - 'message' => (string)$this->l10n->t('Unsatisfied backend parameters') |
|
208 | + 'message' => (string) $this->l10n->t('Unsatisfied backend parameters') |
|
209 | 209 | ), |
210 | 210 | Http::STATUS_UNPROCESSABLE_ENTITY |
211 | 211 | ); |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | // unsatisfied parameters |
215 | 215 | return new DataResponse( |
216 | 216 | [ |
217 | - 'message' => (string)$this->l10n->t('Unsatisfied authentication mechanism parameters') |
|
217 | + 'message' => (string) $this->l10n->t('Unsatisfied authentication mechanism parameters') |
|
218 | 218 | ], |
219 | 219 | Http::STATUS_UNPROCESSABLE_ENTITY |
220 | 220 | ); |
@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | } catch (NotFoundException $e) { |
307 | 307 | return new DataResponse( |
308 | 308 | [ |
309 | - 'message' => (string)$this->l10n->t('Storage with ID "%d" not found', array($id)) |
|
309 | + 'message' => (string) $this->l10n->t('Storage with ID "%d" not found', array($id)) |
|
310 | 310 | ], |
311 | 311 | Http::STATUS_NOT_FOUND |
312 | 312 | ); |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | } catch (NotFoundException $e) { |
332 | 332 | return new DataResponse( |
333 | 333 | [ |
334 | - 'message' => (string)$this->l10n->t('Storage with ID "%d" not found', array($id)) |
|
334 | + 'message' => (string) $this->l10n->t('Storage with ID "%d" not found', array($id)) |
|
335 | 335 | ], |
336 | 336 | Http::STATUS_NOT_FOUND |
337 | 337 | ); |
@@ -43,165 +43,165 @@ |
||
43 | 43 | * User global storages controller |
44 | 44 | */ |
45 | 45 | class UserGlobalStoragesController extends StoragesController { |
46 | - /** |
|
47 | - * @var IUserSession |
|
48 | - */ |
|
49 | - private $userSession; |
|
50 | - |
|
51 | - /** |
|
52 | - * Creates a new user global storages controller. |
|
53 | - * |
|
54 | - * @param string $AppName application name |
|
55 | - * @param IRequest $request request object |
|
56 | - * @param IL10N $l10n l10n service |
|
57 | - * @param UserGlobalStoragesService $userGlobalStoragesService storage service |
|
58 | - * @param IUserSession $userSession |
|
59 | - */ |
|
60 | - public function __construct( |
|
61 | - $AppName, |
|
62 | - IRequest $request, |
|
63 | - IL10N $l10n, |
|
64 | - UserGlobalStoragesService $userGlobalStoragesService, |
|
65 | - IUserSession $userSession, |
|
66 | - ILogger $logger |
|
67 | - ) { |
|
68 | - parent::__construct( |
|
69 | - $AppName, |
|
70 | - $request, |
|
71 | - $l10n, |
|
72 | - $userGlobalStoragesService, |
|
73 | - $logger |
|
74 | - ); |
|
75 | - $this->userSession = $userSession; |
|
76 | - } |
|
77 | - |
|
78 | - /** |
|
79 | - * Get all storage entries |
|
80 | - * |
|
81 | - * @return DataResponse |
|
82 | - * |
|
83 | - * @NoAdminRequired |
|
84 | - */ |
|
85 | - public function index() { |
|
86 | - $storages = $this->service->getUniqueStorages(); |
|
87 | - |
|
88 | - // remove configuration data, this must be kept private |
|
89 | - foreach ($storages as $storage) { |
|
90 | - $this->sanitizeStorage($storage); |
|
91 | - } |
|
92 | - |
|
93 | - return new DataResponse( |
|
94 | - $storages, |
|
95 | - Http::STATUS_OK |
|
96 | - ); |
|
97 | - } |
|
98 | - |
|
99 | - protected function manipulateStorageConfig(StorageConfig $storage) { |
|
100 | - /** @var AuthMechanism */ |
|
101 | - $authMechanism = $storage->getAuthMechanism(); |
|
102 | - $authMechanism->manipulateStorageConfig($storage, $this->userSession->getUser()); |
|
103 | - /** @var Backend */ |
|
104 | - $backend = $storage->getBackend(); |
|
105 | - $backend->manipulateStorageConfig($storage, $this->userSession->getUser()); |
|
106 | - } |
|
107 | - |
|
108 | - /** |
|
109 | - * Get an external storage entry. |
|
110 | - * |
|
111 | - * @param int $id storage id |
|
112 | - * @param bool $testOnly whether to storage should only test the connection or do more things |
|
113 | - * @return DataResponse |
|
114 | - * |
|
115 | - * @NoAdminRequired |
|
116 | - */ |
|
117 | - public function show($id, $testOnly = true) { |
|
118 | - try { |
|
119 | - $storage = $this->service->getStorage($id); |
|
120 | - |
|
121 | - $this->updateStorageStatus($storage, $testOnly); |
|
122 | - } catch (NotFoundException $e) { |
|
123 | - return new DataResponse( |
|
124 | - [ |
|
125 | - 'message' => (string)$this->l10n->t('Storage with ID "%d" not found', array($id)) |
|
126 | - ], |
|
127 | - Http::STATUS_NOT_FOUND |
|
128 | - ); |
|
129 | - } |
|
130 | - |
|
131 | - $this->sanitizeStorage($storage); |
|
132 | - |
|
133 | - return new DataResponse( |
|
134 | - $storage, |
|
135 | - Http::STATUS_OK |
|
136 | - ); |
|
137 | - } |
|
138 | - |
|
139 | - /** |
|
140 | - * Update an external storage entry. |
|
141 | - * Only allows setting user provided backend fields |
|
142 | - * |
|
143 | - * @param int $id storage id |
|
144 | - * @param array $backendOptions backend-specific options |
|
145 | - * @param bool $testOnly whether to storage should only test the connection or do more things |
|
146 | - * |
|
147 | - * @return DataResponse |
|
148 | - * |
|
149 | - * @NoAdminRequired |
|
150 | - */ |
|
151 | - public function update( |
|
152 | - $id, |
|
153 | - $backendOptions, |
|
154 | - $testOnly = true |
|
155 | - ) { |
|
156 | - try { |
|
157 | - $storage = $this->service->getStorage($id); |
|
158 | - $authMechanism = $storage->getAuthMechanism(); |
|
159 | - if ($authMechanism instanceof IUserProvided) { |
|
160 | - $authMechanism->saveBackendOptions($this->userSession->getUser(), $id, $backendOptions); |
|
161 | - $authMechanism->manipulateStorageConfig($storage, $this->userSession->getUser()); |
|
162 | - } else { |
|
163 | - return new DataResponse( |
|
164 | - [ |
|
165 | - 'message' => (string)$this->l10n->t('Storage with ID "%d" is not user editable', array($id)) |
|
166 | - ], |
|
167 | - Http::STATUS_FORBIDDEN |
|
168 | - ); |
|
169 | - } |
|
170 | - } catch (NotFoundException $e) { |
|
171 | - return new DataResponse( |
|
172 | - [ |
|
173 | - 'message' => (string)$this->l10n->t('Storage with ID "%d" not found', array($id)) |
|
174 | - ], |
|
175 | - Http::STATUS_NOT_FOUND |
|
176 | - ); |
|
177 | - } |
|
178 | - |
|
179 | - $this->updateStorageStatus($storage, $testOnly); |
|
180 | - $this->sanitizeStorage($storage); |
|
181 | - |
|
182 | - return new DataResponse( |
|
183 | - $storage, |
|
184 | - Http::STATUS_OK |
|
185 | - ); |
|
186 | - |
|
187 | - } |
|
188 | - |
|
189 | - /** |
|
190 | - * Remove sensitive data from a StorageConfig before returning it to the user |
|
191 | - * |
|
192 | - * @param StorageConfig $storage |
|
193 | - */ |
|
194 | - protected function sanitizeStorage(StorageConfig $storage) { |
|
195 | - $storage->setBackendOptions([]); |
|
196 | - $storage->setMountOptions([]); |
|
197 | - |
|
198 | - if ($storage->getAuthMechanism() instanceof IUserProvided) { |
|
199 | - try { |
|
200 | - $storage->getAuthMechanism()->manipulateStorageConfig($storage, $this->userSession->getUser()); |
|
201 | - } catch (InsufficientDataForMeaningfulAnswerException $e) { |
|
202 | - // not configured yet |
|
203 | - } |
|
204 | - } |
|
205 | - } |
|
46 | + /** |
|
47 | + * @var IUserSession |
|
48 | + */ |
|
49 | + private $userSession; |
|
50 | + |
|
51 | + /** |
|
52 | + * Creates a new user global storages controller. |
|
53 | + * |
|
54 | + * @param string $AppName application name |
|
55 | + * @param IRequest $request request object |
|
56 | + * @param IL10N $l10n l10n service |
|
57 | + * @param UserGlobalStoragesService $userGlobalStoragesService storage service |
|
58 | + * @param IUserSession $userSession |
|
59 | + */ |
|
60 | + public function __construct( |
|
61 | + $AppName, |
|
62 | + IRequest $request, |
|
63 | + IL10N $l10n, |
|
64 | + UserGlobalStoragesService $userGlobalStoragesService, |
|
65 | + IUserSession $userSession, |
|
66 | + ILogger $logger |
|
67 | + ) { |
|
68 | + parent::__construct( |
|
69 | + $AppName, |
|
70 | + $request, |
|
71 | + $l10n, |
|
72 | + $userGlobalStoragesService, |
|
73 | + $logger |
|
74 | + ); |
|
75 | + $this->userSession = $userSession; |
|
76 | + } |
|
77 | + |
|
78 | + /** |
|
79 | + * Get all storage entries |
|
80 | + * |
|
81 | + * @return DataResponse |
|
82 | + * |
|
83 | + * @NoAdminRequired |
|
84 | + */ |
|
85 | + public function index() { |
|
86 | + $storages = $this->service->getUniqueStorages(); |
|
87 | + |
|
88 | + // remove configuration data, this must be kept private |
|
89 | + foreach ($storages as $storage) { |
|
90 | + $this->sanitizeStorage($storage); |
|
91 | + } |
|
92 | + |
|
93 | + return new DataResponse( |
|
94 | + $storages, |
|
95 | + Http::STATUS_OK |
|
96 | + ); |
|
97 | + } |
|
98 | + |
|
99 | + protected function manipulateStorageConfig(StorageConfig $storage) { |
|
100 | + /** @var AuthMechanism */ |
|
101 | + $authMechanism = $storage->getAuthMechanism(); |
|
102 | + $authMechanism->manipulateStorageConfig($storage, $this->userSession->getUser()); |
|
103 | + /** @var Backend */ |
|
104 | + $backend = $storage->getBackend(); |
|
105 | + $backend->manipulateStorageConfig($storage, $this->userSession->getUser()); |
|
106 | + } |
|
107 | + |
|
108 | + /** |
|
109 | + * Get an external storage entry. |
|
110 | + * |
|
111 | + * @param int $id storage id |
|
112 | + * @param bool $testOnly whether to storage should only test the connection or do more things |
|
113 | + * @return DataResponse |
|
114 | + * |
|
115 | + * @NoAdminRequired |
|
116 | + */ |
|
117 | + public function show($id, $testOnly = true) { |
|
118 | + try { |
|
119 | + $storage = $this->service->getStorage($id); |
|
120 | + |
|
121 | + $this->updateStorageStatus($storage, $testOnly); |
|
122 | + } catch (NotFoundException $e) { |
|
123 | + return new DataResponse( |
|
124 | + [ |
|
125 | + 'message' => (string)$this->l10n->t('Storage with ID "%d" not found', array($id)) |
|
126 | + ], |
|
127 | + Http::STATUS_NOT_FOUND |
|
128 | + ); |
|
129 | + } |
|
130 | + |
|
131 | + $this->sanitizeStorage($storage); |
|
132 | + |
|
133 | + return new DataResponse( |
|
134 | + $storage, |
|
135 | + Http::STATUS_OK |
|
136 | + ); |
|
137 | + } |
|
138 | + |
|
139 | + /** |
|
140 | + * Update an external storage entry. |
|
141 | + * Only allows setting user provided backend fields |
|
142 | + * |
|
143 | + * @param int $id storage id |
|
144 | + * @param array $backendOptions backend-specific options |
|
145 | + * @param bool $testOnly whether to storage should only test the connection or do more things |
|
146 | + * |
|
147 | + * @return DataResponse |
|
148 | + * |
|
149 | + * @NoAdminRequired |
|
150 | + */ |
|
151 | + public function update( |
|
152 | + $id, |
|
153 | + $backendOptions, |
|
154 | + $testOnly = true |
|
155 | + ) { |
|
156 | + try { |
|
157 | + $storage = $this->service->getStorage($id); |
|
158 | + $authMechanism = $storage->getAuthMechanism(); |
|
159 | + if ($authMechanism instanceof IUserProvided) { |
|
160 | + $authMechanism->saveBackendOptions($this->userSession->getUser(), $id, $backendOptions); |
|
161 | + $authMechanism->manipulateStorageConfig($storage, $this->userSession->getUser()); |
|
162 | + } else { |
|
163 | + return new DataResponse( |
|
164 | + [ |
|
165 | + 'message' => (string)$this->l10n->t('Storage with ID "%d" is not user editable', array($id)) |
|
166 | + ], |
|
167 | + Http::STATUS_FORBIDDEN |
|
168 | + ); |
|
169 | + } |
|
170 | + } catch (NotFoundException $e) { |
|
171 | + return new DataResponse( |
|
172 | + [ |
|
173 | + 'message' => (string)$this->l10n->t('Storage with ID "%d" not found', array($id)) |
|
174 | + ], |
|
175 | + Http::STATUS_NOT_FOUND |
|
176 | + ); |
|
177 | + } |
|
178 | + |
|
179 | + $this->updateStorageStatus($storage, $testOnly); |
|
180 | + $this->sanitizeStorage($storage); |
|
181 | + |
|
182 | + return new DataResponse( |
|
183 | + $storage, |
|
184 | + Http::STATUS_OK |
|
185 | + ); |
|
186 | + |
|
187 | + } |
|
188 | + |
|
189 | + /** |
|
190 | + * Remove sensitive data from a StorageConfig before returning it to the user |
|
191 | + * |
|
192 | + * @param StorageConfig $storage |
|
193 | + */ |
|
194 | + protected function sanitizeStorage(StorageConfig $storage) { |
|
195 | + $storage->setBackendOptions([]); |
|
196 | + $storage->setMountOptions([]); |
|
197 | + |
|
198 | + if ($storage->getAuthMechanism() instanceof IUserProvided) { |
|
199 | + try { |
|
200 | + $storage->getAuthMechanism()->manipulateStorageConfig($storage, $this->userSession->getUser()); |
|
201 | + } catch (InsufficientDataForMeaningfulAnswerException $e) { |
|
202 | + // not configured yet |
|
203 | + } |
|
204 | + } |
|
205 | + } |
|
206 | 206 | |
207 | 207 | } |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | } catch (NotFoundException $e) { |
123 | 123 | return new DataResponse( |
124 | 124 | [ |
125 | - 'message' => (string)$this->l10n->t('Storage with ID "%d" not found', array($id)) |
|
125 | + 'message' => (string) $this->l10n->t('Storage with ID "%d" not found', array($id)) |
|
126 | 126 | ], |
127 | 127 | Http::STATUS_NOT_FOUND |
128 | 128 | ); |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | } else { |
163 | 163 | return new DataResponse( |
164 | 164 | [ |
165 | - 'message' => (string)$this->l10n->t('Storage with ID "%d" is not user editable', array($id)) |
|
165 | + 'message' => (string) $this->l10n->t('Storage with ID "%d" is not user editable', array($id)) |
|
166 | 166 | ], |
167 | 167 | Http::STATUS_FORBIDDEN |
168 | 168 | ); |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | } catch (NotFoundException $e) { |
171 | 171 | return new DataResponse( |
172 | 172 | [ |
173 | - 'message' => (string)$this->l10n->t('Storage with ID "%d" not found', array($id)) |
|
173 | + 'message' => (string) $this->l10n->t('Storage with ID "%d" not found', array($id)) |
|
174 | 174 | ], |
175 | 175 | Http::STATUS_NOT_FOUND |
176 | 176 | ); |
@@ -27,73 +27,73 @@ |
||
27 | 27 | |
28 | 28 | class Hooks { |
29 | 29 | |
30 | - /** @var AccountManager */ |
|
31 | - private $accountManager = null; |
|
32 | - |
|
33 | - /** @var ILogger */ |
|
34 | - private $logger; |
|
35 | - |
|
36 | - /** |
|
37 | - * Hooks constructor. |
|
38 | - * |
|
39 | - * @param ILogger $logger |
|
40 | - */ |
|
41 | - public function __construct(ILogger $logger) { |
|
42 | - $this->logger = $logger; |
|
43 | - } |
|
44 | - |
|
45 | - /** |
|
46 | - * update accounts table if email address or display name was changed from outside |
|
47 | - * |
|
48 | - * @param array $params |
|
49 | - */ |
|
50 | - public function changeUserHook($params) { |
|
51 | - |
|
52 | - $accountManager = $this->getAccountManager(); |
|
53 | - |
|
54 | - /** @var IUser $user */ |
|
55 | - $user = isset($params['user']) ? $params['user'] : null; |
|
56 | - $feature = isset($params['feature']) ? $params['feature'] : null; |
|
57 | - $newValue = isset($params['value']) ? $params['value'] : null; |
|
58 | - |
|
59 | - if (is_null($user) || is_null($feature) || is_null($newValue)) { |
|
60 | - $this->logger->warning('Missing expected parameters in change user hook'); |
|
61 | - return; |
|
62 | - } |
|
63 | - |
|
64 | - $accountData = $accountManager->getUser($user); |
|
65 | - |
|
66 | - switch ($feature) { |
|
67 | - case 'eMailAddress': |
|
68 | - if ($accountData[AccountManager::PROPERTY_EMAIL]['value'] !== $newValue) { |
|
69 | - $accountData[AccountManager::PROPERTY_EMAIL]['value'] = $newValue; |
|
70 | - $accountManager->updateUser($user, $accountData); |
|
71 | - } |
|
72 | - break; |
|
73 | - case 'displayName': |
|
74 | - if ($accountData[AccountManager::PROPERTY_DISPLAYNAME]['value'] !== $newValue) { |
|
75 | - $accountData[AccountManager::PROPERTY_DISPLAYNAME]['value'] = $newValue; |
|
76 | - $accountManager->updateUser($user, $accountData); |
|
77 | - } |
|
78 | - break; |
|
79 | - } |
|
80 | - |
|
81 | - } |
|
82 | - |
|
83 | - /** |
|
84 | - * return instance of accountManager |
|
85 | - * |
|
86 | - * @return AccountManager |
|
87 | - */ |
|
88 | - protected function getAccountManager() { |
|
89 | - if (is_null($this->accountManager)) { |
|
90 | - $this->accountManager = new AccountManager( |
|
91 | - \OC::$server->getDatabaseConnection(), |
|
92 | - \OC::$server->getEventDispatcher(), |
|
93 | - \OC::$server->getJobList() |
|
94 | - ); |
|
95 | - } |
|
96 | - return $this->accountManager; |
|
97 | - } |
|
30 | + /** @var AccountManager */ |
|
31 | + private $accountManager = null; |
|
32 | + |
|
33 | + /** @var ILogger */ |
|
34 | + private $logger; |
|
35 | + |
|
36 | + /** |
|
37 | + * Hooks constructor. |
|
38 | + * |
|
39 | + * @param ILogger $logger |
|
40 | + */ |
|
41 | + public function __construct(ILogger $logger) { |
|
42 | + $this->logger = $logger; |
|
43 | + } |
|
44 | + |
|
45 | + /** |
|
46 | + * update accounts table if email address or display name was changed from outside |
|
47 | + * |
|
48 | + * @param array $params |
|
49 | + */ |
|
50 | + public function changeUserHook($params) { |
|
51 | + |
|
52 | + $accountManager = $this->getAccountManager(); |
|
53 | + |
|
54 | + /** @var IUser $user */ |
|
55 | + $user = isset($params['user']) ? $params['user'] : null; |
|
56 | + $feature = isset($params['feature']) ? $params['feature'] : null; |
|
57 | + $newValue = isset($params['value']) ? $params['value'] : null; |
|
58 | + |
|
59 | + if (is_null($user) || is_null($feature) || is_null($newValue)) { |
|
60 | + $this->logger->warning('Missing expected parameters in change user hook'); |
|
61 | + return; |
|
62 | + } |
|
63 | + |
|
64 | + $accountData = $accountManager->getUser($user); |
|
65 | + |
|
66 | + switch ($feature) { |
|
67 | + case 'eMailAddress': |
|
68 | + if ($accountData[AccountManager::PROPERTY_EMAIL]['value'] !== $newValue) { |
|
69 | + $accountData[AccountManager::PROPERTY_EMAIL]['value'] = $newValue; |
|
70 | + $accountManager->updateUser($user, $accountData); |
|
71 | + } |
|
72 | + break; |
|
73 | + case 'displayName': |
|
74 | + if ($accountData[AccountManager::PROPERTY_DISPLAYNAME]['value'] !== $newValue) { |
|
75 | + $accountData[AccountManager::PROPERTY_DISPLAYNAME]['value'] = $newValue; |
|
76 | + $accountManager->updateUser($user, $accountData); |
|
77 | + } |
|
78 | + break; |
|
79 | + } |
|
80 | + |
|
81 | + } |
|
82 | + |
|
83 | + /** |
|
84 | + * return instance of accountManager |
|
85 | + * |
|
86 | + * @return AccountManager |
|
87 | + */ |
|
88 | + protected function getAccountManager() { |
|
89 | + if (is_null($this->accountManager)) { |
|
90 | + $this->accountManager = new AccountManager( |
|
91 | + \OC::$server->getDatabaseConnection(), |
|
92 | + \OC::$server->getEventDispatcher(), |
|
93 | + \OC::$server->getJobList() |
|
94 | + ); |
|
95 | + } |
|
96 | + return $this->accountManager; |
|
97 | + } |
|
98 | 98 | |
99 | 99 | } |
@@ -97,7 +97,19 @@ |
||
97 | 97 | <p><label for="ldap_group_display_name"><?php p($l->t('Group Display Name Field'));?></label><input type="text" id="ldap_group_display_name" name="ldap_group_display_name" data-default="<?php p($_['ldap_group_display_name_default']); ?>" title="<?php p($l->t('The LDAP attribute to use to generate the groups\'s display name.'));?>" /></p> |
98 | 98 | <p><label for="ldap_base_groups"><?php p($l->t('Base Group Tree'));?></label><textarea id="ldap_base_groups" name="ldap_base_groups" placeholder="<?php p($l->t('One Group Base DN per line'));?>" data-default="<?php p($_['ldap_base_groups_default']); ?>" title="<?php p($l->t('Base Group Tree'));?>"></textarea></p> |
99 | 99 | <p><label for="ldap_attributes_for_group_search"><?php p($l->t('Group Search Attributes'));?></label><textarea id="ldap_attributes_for_group_search" name="ldap_attributes_for_group_search" placeholder="<?php p($l->t('Optional; one attribute per line'));?>" data-default="<?php p($_['ldap_attributes_for_group_search_default']); ?>" title="<?php p($l->t('Group Search Attributes'));?>"></textarea></p> |
100 | - <p><label for="ldap_group_member_assoc_attribute"><?php p($l->t('Group-Member association'));?></label><select id="ldap_group_member_assoc_attribute" name="ldap_group_member_assoc_attribute" data-default="<?php p($_['ldap_group_member_assoc_attribute_default']); ?>" ><option value="uniqueMember"<?php if (isset($_['ldap_group_member_assoc_attribute']) && ($_['ldap_group_member_assoc_attribute'] === 'uniqueMember')) p(' selected'); ?>>uniqueMember</option><option value="memberUid"<?php if (isset($_['ldap_group_member_assoc_attribute']) && ($_['ldap_group_member_assoc_attribute'] === 'memberUid')) p(' selected'); ?>>memberUid</option><option value="member"<?php if (isset($_['ldap_group_member_assoc_attribute']) && ($_['ldap_group_member_assoc_attribute'] === 'member')) p(' selected'); ?>>member (AD)</option><option value="gidNumber"<?php if (isset($_['ldap_group_member_assoc_attribute']) && ($_['ldap_group_member_assoc_attribute'] === 'gidNumber')) p(' selected'); ?>>gidNumber</option></select></p> <p><label for="ldap_dynamic_group_member_url"><?php p($l->t('Dynamic Group Member URL'));?></label><input type="text" id="ldap_dynamic_group_member_url" name="ldap_dynamic_group_member_url" title="<?php p($l->t('The LDAP attribute that on group objects contains an LDAP search URL that determines what objects belong to the group. (An empty setting disables dynamic group membership functionality.)'));?>" data-default="<?php p($_['ldap_dynamic_group_member_url_default']); ?>" /></p> |
|
100 | + <p><label for="ldap_group_member_assoc_attribute"><?php p($l->t('Group-Member association'));?></label><select id="ldap_group_member_assoc_attribute" name="ldap_group_member_assoc_attribute" data-default="<?php p($_['ldap_group_member_assoc_attribute_default']); ?>" ><option value="uniqueMember"<?php if (isset($_['ldap_group_member_assoc_attribute']) && ($_['ldap_group_member_assoc_attribute'] === 'uniqueMember')) { |
|
101 | + p(' selected'); |
|
102 | +} |
|
103 | +?>>uniqueMember</option><option value="memberUid"<?php if (isset($_['ldap_group_member_assoc_attribute']) && ($_['ldap_group_member_assoc_attribute'] === 'memberUid')) { |
|
104 | + p(' selected'); |
|
105 | +} |
|
106 | +?>>memberUid</option><option value="member"<?php if (isset($_['ldap_group_member_assoc_attribute']) && ($_['ldap_group_member_assoc_attribute'] === 'member')) { |
|
107 | + p(' selected'); |
|
108 | +} |
|
109 | +?>>member (AD)</option><option value="gidNumber"<?php if (isset($_['ldap_group_member_assoc_attribute']) && ($_['ldap_group_member_assoc_attribute'] === 'gidNumber')) { |
|
110 | + p(' selected'); |
|
111 | +} |
|
112 | +?>>gidNumber</option></select></p> <p><label for="ldap_dynamic_group_member_url"><?php p($l->t('Dynamic Group Member URL'));?></label><input type="text" id="ldap_dynamic_group_member_url" name="ldap_dynamic_group_member_url" title="<?php p($l->t('The LDAP attribute that on group objects contains an LDAP search URL that determines what objects belong to the group. (An empty setting disables dynamic group membership functionality.)'));?>" data-default="<?php p($_['ldap_dynamic_group_member_url_default']); ?>" /></p> |
|
101 | 113 | <p><label for="ldap_nested_groups"><?php p($l->t('Nested Groups'));?></label><input type="checkbox" id="ldap_nested_groups" name="ldap_nested_groups" value="1" data-default="<?php p($_['ldap_nested_groups_default']); ?>" title="<?php p($l->t('When switched on, groups that contain groups are supported. (Only works if the group member attribute contains DNs.)'));?>" /></p> |
102 | 114 | <p><label for="ldap_paging_size"><?php p($l->t('Paging chunksize'));?></label><input type="number" id="ldap_paging_size" name="ldap_paging_size" title="<?php p($l->t('Chunksize used for paged LDAP searches that may return bulky results like user or group enumeration. (Setting it 0 disables paged LDAP searches in those situations.)'));?>" data-default="<?php p($_['ldap_paging_size_default']); ?>" /></p> |
103 | 115 | <p><label for="ldap_turn_on_pwd_change"><?php p($l->t('Enable LDAP password changes per user'));?></label><span class="inlinetable"><span class="tablerow left"><input type="checkbox" id="ldap_turn_on_pwd_change" name="ldap_turn_on_pwd_change" value="1" data-default="<?php p($_['ldap_turn_on_pwd_change_default']); ?>" title="<?php p($l->t('Allow LDAP users to change their password and allow Super Administrators and Group Administrators to change the password of their LDAP users. Only works when access control policies are configured accordingly on the LDAP server. As passwords are sent in plaintext to the LDAP server, transport encryption must be used and password hashing should be configured on the LDAP server.'));?>" /><span class="tablecell"><?php p($l->t('(New password is sent as plain text to LDAP)'));?></span></span> |
@@ -5,46 +5,46 @@ discard block |
||
5 | 5 | vendor_style('user_ldap', 'ui-multiselect/jquery.multiselect'); |
6 | 6 | |
7 | 7 | script('user_ldap', [ |
8 | - 'wizard/controller', |
|
9 | - 'wizard/configModel', |
|
10 | - 'wizard/view', |
|
11 | - 'wizard/wizardObject', |
|
12 | - 'wizard/wizardTabGeneric', |
|
13 | - 'wizard/wizardTabElementary', |
|
14 | - 'wizard/wizardTabAbstractFilter', |
|
15 | - 'wizard/wizardTabUserFilter', |
|
16 | - 'wizard/wizardTabLoginFilter', |
|
17 | - 'wizard/wizardTabGroupFilter', |
|
18 | - 'wizard/wizardTabAdvanced', |
|
19 | - 'wizard/wizardTabExpert', |
|
20 | - 'wizard/wizardDetectorQueue', |
|
21 | - 'wizard/wizardDetectorGeneric', |
|
22 | - 'wizard/wizardDetectorPort', |
|
23 | - 'wizard/wizardDetectorBaseDN', |
|
24 | - 'wizard/wizardDetectorFeatureAbstract', |
|
25 | - 'wizard/wizardDetectorUserObjectClasses', |
|
26 | - 'wizard/wizardDetectorGroupObjectClasses', |
|
27 | - 'wizard/wizardDetectorGroupsForUsers', |
|
28 | - 'wizard/wizardDetectorGroupsForGroups', |
|
29 | - 'wizard/wizardDetectorSimpleRequestAbstract', |
|
30 | - 'wizard/wizardDetectorFilterUser', |
|
31 | - 'wizard/wizardDetectorFilterLogin', |
|
32 | - 'wizard/wizardDetectorFilterGroup', |
|
33 | - 'wizard/wizardDetectorUserCount', |
|
34 | - 'wizard/wizardDetectorGroupCount', |
|
35 | - 'wizard/wizardDetectorEmailAttribute', |
|
36 | - 'wizard/wizardDetectorUserDisplayNameAttribute', |
|
37 | - 'wizard/wizardDetectorUserGroupAssociation', |
|
38 | - 'wizard/wizardDetectorAvailableAttributes', |
|
39 | - 'wizard/wizardDetectorTestAbstract', |
|
40 | - 'wizard/wizardDetectorTestLoginName', |
|
41 | - 'wizard/wizardDetectorTestBaseDN', |
|
42 | - 'wizard/wizardDetectorTestConfiguration', |
|
43 | - 'wizard/wizardDetectorClearUserMappings', |
|
44 | - 'wizard/wizardDetectorClearGroupMappings', |
|
45 | - 'wizard/wizardFilterOnType', |
|
46 | - 'wizard/wizardFilterOnTypeFactory', |
|
47 | - 'wizard/wizard' |
|
8 | + 'wizard/controller', |
|
9 | + 'wizard/configModel', |
|
10 | + 'wizard/view', |
|
11 | + 'wizard/wizardObject', |
|
12 | + 'wizard/wizardTabGeneric', |
|
13 | + 'wizard/wizardTabElementary', |
|
14 | + 'wizard/wizardTabAbstractFilter', |
|
15 | + 'wizard/wizardTabUserFilter', |
|
16 | + 'wizard/wizardTabLoginFilter', |
|
17 | + 'wizard/wizardTabGroupFilter', |
|
18 | + 'wizard/wizardTabAdvanced', |
|
19 | + 'wizard/wizardTabExpert', |
|
20 | + 'wizard/wizardDetectorQueue', |
|
21 | + 'wizard/wizardDetectorGeneric', |
|
22 | + 'wizard/wizardDetectorPort', |
|
23 | + 'wizard/wizardDetectorBaseDN', |
|
24 | + 'wizard/wizardDetectorFeatureAbstract', |
|
25 | + 'wizard/wizardDetectorUserObjectClasses', |
|
26 | + 'wizard/wizardDetectorGroupObjectClasses', |
|
27 | + 'wizard/wizardDetectorGroupsForUsers', |
|
28 | + 'wizard/wizardDetectorGroupsForGroups', |
|
29 | + 'wizard/wizardDetectorSimpleRequestAbstract', |
|
30 | + 'wizard/wizardDetectorFilterUser', |
|
31 | + 'wizard/wizardDetectorFilterLogin', |
|
32 | + 'wizard/wizardDetectorFilterGroup', |
|
33 | + 'wizard/wizardDetectorUserCount', |
|
34 | + 'wizard/wizardDetectorGroupCount', |
|
35 | + 'wizard/wizardDetectorEmailAttribute', |
|
36 | + 'wizard/wizardDetectorUserDisplayNameAttribute', |
|
37 | + 'wizard/wizardDetectorUserGroupAssociation', |
|
38 | + 'wizard/wizardDetectorAvailableAttributes', |
|
39 | + 'wizard/wizardDetectorTestAbstract', |
|
40 | + 'wizard/wizardDetectorTestLoginName', |
|
41 | + 'wizard/wizardDetectorTestBaseDN', |
|
42 | + 'wizard/wizardDetectorTestConfiguration', |
|
43 | + 'wizard/wizardDetectorClearUserMappings', |
|
44 | + 'wizard/wizardDetectorClearGroupMappings', |
|
45 | + 'wizard/wizardFilterOnType', |
|
46 | + 'wizard/wizardFilterOnTypeFactory', |
|
47 | + 'wizard/wizard' |
|
48 | 48 | ]); |
49 | 49 | |
50 | 50 | style('user_ldap', 'settings'); |
@@ -67,10 +67,10 @@ discard block |
||
67 | 67 | <li class="ldapSettingsTabs"><a href="#ldapSettings-1"><?php p($l->t('Advanced'));?></a></li> |
68 | 68 | </ul> |
69 | 69 | <?php |
70 | - if(!function_exists('ldap_connect')) { |
|
71 | - print_unescaped('<p class="ldapwarning">'.$l->t('<b>Warning:</b> The PHP LDAP module is not installed, the backend will not work. Please ask your system administrator to install it.').'</p>'); |
|
72 | - } |
|
73 | - ?> |
|
70 | + if(!function_exists('ldap_connect')) { |
|
71 | + print_unescaped('<p class="ldapwarning">'.$l->t('<b>Warning:</b> The PHP LDAP module is not installed, the backend will not work. Please ask your system administrator to install it.').'</p>'); |
|
72 | + } |
|
73 | + ?> |
|
74 | 74 | <?php require_once __DIR__ . '/part.wizard-server.php'; ?> |
75 | 75 | <?php require_once __DIR__ . '/part.wizard-userfilter.php'; ?> |
76 | 76 | <?php require_once __DIR__ . '/part.wizard-loginfilter.php'; ?> |
@@ -59,71 +59,71 @@ |
||
59 | 59 | |
60 | 60 | <div id="ldapSettings"> |
61 | 61 | <ul> |
62 | - <li id="#ldapWizard1"><a href="#ldapWizard1"><?php p($l->t('Server'));?></a></li> |
|
63 | - <li id="#ldapWizard2"><a href="#ldapWizard2"><?php p($l->t('Users'));?></a></li> |
|
64 | - <li id="#ldapWizard3"><a href="#ldapWizard3"><?php p($l->t('Login Attributes'));?></a></li> |
|
65 | - <li id="#ldapWizard4"><a href="#ldapWizard4"><?php p($l->t('Groups'));?></a></li> |
|
66 | - <li class="ldapSettingsTabs"><a href="#ldapSettings-2"><?php p($l->t('Expert'));?></a></li> |
|
67 | - <li class="ldapSettingsTabs"><a href="#ldapSettings-1"><?php p($l->t('Advanced'));?></a></li> |
|
62 | + <li id="#ldapWizard1"><a href="#ldapWizard1"><?php p($l->t('Server')); ?></a></li> |
|
63 | + <li id="#ldapWizard2"><a href="#ldapWizard2"><?php p($l->t('Users')); ?></a></li> |
|
64 | + <li id="#ldapWizard3"><a href="#ldapWizard3"><?php p($l->t('Login Attributes')); ?></a></li> |
|
65 | + <li id="#ldapWizard4"><a href="#ldapWizard4"><?php p($l->t('Groups')); ?></a></li> |
|
66 | + <li class="ldapSettingsTabs"><a href="#ldapSettings-2"><?php p($l->t('Expert')); ?></a></li> |
|
67 | + <li class="ldapSettingsTabs"><a href="#ldapSettings-1"><?php p($l->t('Advanced')); ?></a></li> |
|
68 | 68 | </ul> |
69 | 69 | <?php |
70 | - if(!function_exists('ldap_connect')) { |
|
70 | + if (!function_exists('ldap_connect')) { |
|
71 | 71 | print_unescaped('<p class="ldapwarning">'.$l->t('<b>Warning:</b> The PHP LDAP module is not installed, the backend will not work. Please ask your system administrator to install it.').'</p>'); |
72 | 72 | } |
73 | 73 | ?> |
74 | - <?php require_once __DIR__ . '/part.wizard-server.php'; ?> |
|
75 | - <?php require_once __DIR__ . '/part.wizard-userfilter.php'; ?> |
|
76 | - <?php require_once __DIR__ . '/part.wizard-loginfilter.php'; ?> |
|
77 | - <?php require_once __DIR__ . '/part.wizard-groupfilter.php'; ?> |
|
74 | + <?php require_once __DIR__.'/part.wizard-server.php'; ?> |
|
75 | + <?php require_once __DIR__.'/part.wizard-userfilter.php'; ?> |
|
76 | + <?php require_once __DIR__.'/part.wizard-loginfilter.php'; ?> |
|
77 | + <?php require_once __DIR__.'/part.wizard-groupfilter.php'; ?> |
|
78 | 78 | <fieldset id="ldapSettings-1"> |
79 | 79 | <div id="ldapAdvancedAccordion"> |
80 | - <h3><?php p($l->t('Connection Settings'));?></h3> |
|
80 | + <h3><?php p($l->t('Connection Settings')); ?></h3> |
|
81 | 81 | <div> |
82 | - <p><label for="ldap_configuration_active"><?php p($l->t('Configuration Active'));?></label><input type="checkbox" id="ldap_configuration_active" name="ldap_configuration_active" value="1" data-default="<?php p($_['ldap_configuration_active_default']); ?>" title="<?php p($l->t('When unchecked, this configuration will be skipped.'));?>" /></p> |
|
83 | - <p><label for="ldap_backup_host"><?php p($l->t('Backup (Replica) Host'));?></label><input type="text" id="ldap_backup_host" name="ldap_backup_host" data-default="<?php p($_['ldap_backup_host_default']); ?>" title="<?php p($l->t('Give an optional backup host. It must be a replica of the main LDAP/AD server.'));?>"></p> |
|
84 | - <p><label for="ldap_backup_port"><?php p($l->t('Backup (Replica) Port'));?></label><input type="number" id="ldap_backup_port" name="ldap_backup_port" data-default="<?php p($_['ldap_backup_port_default']); ?>" /></p> |
|
85 | - <p><label for="ldap_override_main_server"><?php p($l->t('Disable Main Server'));?></label><input type="checkbox" id="ldap_override_main_server" name="ldap_override_main_server" value="1" data-default="<?php p($_['ldap_override_main_server_default']); ?>" title="<?php p($l->t('Only connect to the replica server.'));?>" /></p> |
|
86 | - <p><label for="ldap_turn_off_cert_check"><?php p($l->t('Turn off SSL certificate validation.'));?></label><input type="checkbox" id="ldap_turn_off_cert_check" name="ldap_turn_off_cert_check" title="<?php p($l->t('Not recommended, use it for testing only! If connection only works with this option, import the LDAP server\'s SSL certificate in your %s server.', [$theme->getName()] ));?>" data-default="<?php p($_['ldap_turn_off_cert_check_default']); ?>" value="1"><br/></p> |
|
87 | - <p><label for="ldap_cache_ttl"><?php p($l->t('Cache Time-To-Live'));?></label><input type="number" id="ldap_cache_ttl" name="ldap_cache_ttl" title="<?php p($l->t('in seconds. A change empties the cache.'));?>" data-default="<?php p($_['ldap_cache_ttl_default']); ?>" /></p> |
|
82 | + <p><label for="ldap_configuration_active"><?php p($l->t('Configuration Active')); ?></label><input type="checkbox" id="ldap_configuration_active" name="ldap_configuration_active" value="1" data-default="<?php p($_['ldap_configuration_active_default']); ?>" title="<?php p($l->t('When unchecked, this configuration will be skipped.')); ?>" /></p> |
|
83 | + <p><label for="ldap_backup_host"><?php p($l->t('Backup (Replica) Host')); ?></label><input type="text" id="ldap_backup_host" name="ldap_backup_host" data-default="<?php p($_['ldap_backup_host_default']); ?>" title="<?php p($l->t('Give an optional backup host. It must be a replica of the main LDAP/AD server.')); ?>"></p> |
|
84 | + <p><label for="ldap_backup_port"><?php p($l->t('Backup (Replica) Port')); ?></label><input type="number" id="ldap_backup_port" name="ldap_backup_port" data-default="<?php p($_['ldap_backup_port_default']); ?>" /></p> |
|
85 | + <p><label for="ldap_override_main_server"><?php p($l->t('Disable Main Server')); ?></label><input type="checkbox" id="ldap_override_main_server" name="ldap_override_main_server" value="1" data-default="<?php p($_['ldap_override_main_server_default']); ?>" title="<?php p($l->t('Only connect to the replica server.')); ?>" /></p> |
|
86 | + <p><label for="ldap_turn_off_cert_check"><?php p($l->t('Turn off SSL certificate validation.')); ?></label><input type="checkbox" id="ldap_turn_off_cert_check" name="ldap_turn_off_cert_check" title="<?php p($l->t('Not recommended, use it for testing only! If connection only works with this option, import the LDAP server\'s SSL certificate in your %s server.', [$theme->getName()])); ?>" data-default="<?php p($_['ldap_turn_off_cert_check_default']); ?>" value="1"><br/></p> |
|
87 | + <p><label for="ldap_cache_ttl"><?php p($l->t('Cache Time-To-Live')); ?></label><input type="number" id="ldap_cache_ttl" name="ldap_cache_ttl" title="<?php p($l->t('in seconds. A change empties the cache.')); ?>" data-default="<?php p($_['ldap_cache_ttl_default']); ?>" /></p> |
|
88 | 88 | </div> |
89 | - <h3><?php p($l->t('Directory Settings'));?></h3> |
|
89 | + <h3><?php p($l->t('Directory Settings')); ?></h3> |
|
90 | 90 | <div> |
91 | - <p><label for="ldap_display_name"><?php p($l->t('User Display Name Field'));?></label><input type="text" id="ldap_display_name" name="ldap_display_name" data-default="<?php p($_['ldap_display_name_default']); ?>" title="<?php p($l->t('The LDAP attribute to use to generate the user\'s display name.'));?>" /></p> |
|
92 | - <p><label for="ldap_user_display_name_2"><?php p($l->t('2nd User Display Name Field'));?></label><input type="text" id="ldap_user_display_name_2" name="ldap_user_display_name_2" data-default="<?php p($_['ldap_user_display_name_2_default']); ?>" title="<?php p($l->t('Optional. An LDAP attribute to be added to the display name in brackets. Results in e.g. »John Doe ([email protected])«.'));?>" /></p> |
|
93 | - <p><label for="ldap_base_users"><?php p($l->t('Base User Tree'));?></label><textarea id="ldap_base_users" name="ldap_base_users" placeholder="<?php p($l->t('One User Base DN per line'));?>" data-default="<?php p($_['ldap_base_users_default']); ?>" title="<?php p($l->t('Base User Tree'));?>"></textarea></p> |
|
94 | - <p><label for="ldap_attributes_for_user_search"><?php p($l->t('User Search Attributes'));?></label><textarea id="ldap_attributes_for_user_search" name="ldap_attributes_for_user_search" placeholder="<?php p($l->t('Optional; one attribute per line'));?>" data-default="<?php p($_['ldap_attributes_for_user_search_default']); ?>" title="<?php p($l->t('User Search Attributes'));?>"></textarea></p> |
|
95 | - <p><label for="ldap_group_display_name"><?php p($l->t('Group Display Name Field'));?></label><input type="text" id="ldap_group_display_name" name="ldap_group_display_name" data-default="<?php p($_['ldap_group_display_name_default']); ?>" title="<?php p($l->t('The LDAP attribute to use to generate the groups\'s display name.'));?>" /></p> |
|
96 | - <p><label for="ldap_base_groups"><?php p($l->t('Base Group Tree'));?></label><textarea id="ldap_base_groups" name="ldap_base_groups" placeholder="<?php p($l->t('One Group Base DN per line'));?>" data-default="<?php p($_['ldap_base_groups_default']); ?>" title="<?php p($l->t('Base Group Tree'));?>"></textarea></p> |
|
97 | - <p><label for="ldap_attributes_for_group_search"><?php p($l->t('Group Search Attributes'));?></label><textarea id="ldap_attributes_for_group_search" name="ldap_attributes_for_group_search" placeholder="<?php p($l->t('Optional; one attribute per line'));?>" data-default="<?php p($_['ldap_attributes_for_group_search_default']); ?>" title="<?php p($l->t('Group Search Attributes'));?>"></textarea></p> |
|
98 | - <p><label for="ldap_group_member_assoc_attribute"><?php p($l->t('Group-Member association'));?></label><select id="ldap_group_member_assoc_attribute" name="ldap_group_member_assoc_attribute" data-default="<?php p($_['ldap_group_member_assoc_attribute_default']); ?>" ><option value="uniqueMember"<?php if (isset($_['ldap_group_member_assoc_attribute']) && ($_['ldap_group_member_assoc_attribute'] === 'uniqueMember')) p(' selected'); ?>>uniqueMember</option><option value="memberUid"<?php if (isset($_['ldap_group_member_assoc_attribute']) && ($_['ldap_group_member_assoc_attribute'] === 'memberUid')) p(' selected'); ?>>memberUid</option><option value="member"<?php if (isset($_['ldap_group_member_assoc_attribute']) && ($_['ldap_group_member_assoc_attribute'] === 'member')) p(' selected'); ?>>member (AD)</option><option value="gidNumber"<?php if (isset($_['ldap_group_member_assoc_attribute']) && ($_['ldap_group_member_assoc_attribute'] === 'gidNumber')) p(' selected'); ?>>gidNumber</option></select></p> <p><label for="ldap_dynamic_group_member_url"><?php p($l->t('Dynamic Group Member URL'));?></label><input type="text" id="ldap_dynamic_group_member_url" name="ldap_dynamic_group_member_url" title="<?php p($l->t('The LDAP attribute that on group objects contains an LDAP search URL that determines what objects belong to the group. (An empty setting disables dynamic group membership functionality.)'));?>" data-default="<?php p($_['ldap_dynamic_group_member_url_default']); ?>" /></p> |
|
99 | - <p><label for="ldap_nested_groups"><?php p($l->t('Nested Groups'));?></label><input type="checkbox" id="ldap_nested_groups" name="ldap_nested_groups" value="1" data-default="<?php p($_['ldap_nested_groups_default']); ?>" title="<?php p($l->t('When switched on, groups that contain groups are supported. (Only works if the group member attribute contains DNs.)'));?>" /></p> |
|
100 | - <p><label for="ldap_paging_size"><?php p($l->t('Paging chunksize'));?></label><input type="number" id="ldap_paging_size" name="ldap_paging_size" title="<?php p($l->t('Chunksize used for paged LDAP searches that may return bulky results like user or group enumeration. (Setting it 0 disables paged LDAP searches in those situations.)'));?>" data-default="<?php p($_['ldap_paging_size_default']); ?>" /></p> |
|
101 | - <p><label for="ldap_turn_on_pwd_change"><?php p($l->t('Enable LDAP password changes per user'));?></label><span class="inlinetable"><span class="tablerow left"><input type="checkbox" id="ldap_turn_on_pwd_change" name="ldap_turn_on_pwd_change" value="1" data-default="<?php p($_['ldap_turn_on_pwd_change_default']); ?>" title="<?php p($l->t('Allow LDAP users to change their password and allow Super Administrators and Group Administrators to change the password of their LDAP users. Only works when access control policies are configured accordingly on the LDAP server. As passwords are sent in plaintext to the LDAP server, transport encryption must be used and password hashing should be configured on the LDAP server.'));?>" /><span class="tablecell"><?php p($l->t('(New password is sent as plain text to LDAP)'));?></span></span> |
|
91 | + <p><label for="ldap_display_name"><?php p($l->t('User Display Name Field')); ?></label><input type="text" id="ldap_display_name" name="ldap_display_name" data-default="<?php p($_['ldap_display_name_default']); ?>" title="<?php p($l->t('The LDAP attribute to use to generate the user\'s display name.')); ?>" /></p> |
|
92 | + <p><label for="ldap_user_display_name_2"><?php p($l->t('2nd User Display Name Field')); ?></label><input type="text" id="ldap_user_display_name_2" name="ldap_user_display_name_2" data-default="<?php p($_['ldap_user_display_name_2_default']); ?>" title="<?php p($l->t('Optional. An LDAP attribute to be added to the display name in brackets. Results in e.g. »John Doe ([email protected])«.')); ?>" /></p> |
|
93 | + <p><label for="ldap_base_users"><?php p($l->t('Base User Tree')); ?></label><textarea id="ldap_base_users" name="ldap_base_users" placeholder="<?php p($l->t('One User Base DN per line')); ?>" data-default="<?php p($_['ldap_base_users_default']); ?>" title="<?php p($l->t('Base User Tree')); ?>"></textarea></p> |
|
94 | + <p><label for="ldap_attributes_for_user_search"><?php p($l->t('User Search Attributes')); ?></label><textarea id="ldap_attributes_for_user_search" name="ldap_attributes_for_user_search" placeholder="<?php p($l->t('Optional; one attribute per line')); ?>" data-default="<?php p($_['ldap_attributes_for_user_search_default']); ?>" title="<?php p($l->t('User Search Attributes')); ?>"></textarea></p> |
|
95 | + <p><label for="ldap_group_display_name"><?php p($l->t('Group Display Name Field')); ?></label><input type="text" id="ldap_group_display_name" name="ldap_group_display_name" data-default="<?php p($_['ldap_group_display_name_default']); ?>" title="<?php p($l->t('The LDAP attribute to use to generate the groups\'s display name.')); ?>" /></p> |
|
96 | + <p><label for="ldap_base_groups"><?php p($l->t('Base Group Tree')); ?></label><textarea id="ldap_base_groups" name="ldap_base_groups" placeholder="<?php p($l->t('One Group Base DN per line')); ?>" data-default="<?php p($_['ldap_base_groups_default']); ?>" title="<?php p($l->t('Base Group Tree')); ?>"></textarea></p> |
|
97 | + <p><label for="ldap_attributes_for_group_search"><?php p($l->t('Group Search Attributes')); ?></label><textarea id="ldap_attributes_for_group_search" name="ldap_attributes_for_group_search" placeholder="<?php p($l->t('Optional; one attribute per line')); ?>" data-default="<?php p($_['ldap_attributes_for_group_search_default']); ?>" title="<?php p($l->t('Group Search Attributes')); ?>"></textarea></p> |
|
98 | + <p><label for="ldap_group_member_assoc_attribute"><?php p($l->t('Group-Member association')); ?></label><select id="ldap_group_member_assoc_attribute" name="ldap_group_member_assoc_attribute" data-default="<?php p($_['ldap_group_member_assoc_attribute_default']); ?>" ><option value="uniqueMember"<?php if (isset($_['ldap_group_member_assoc_attribute']) && ($_['ldap_group_member_assoc_attribute'] === 'uniqueMember')) p(' selected'); ?>>uniqueMember</option><option value="memberUid"<?php if (isset($_['ldap_group_member_assoc_attribute']) && ($_['ldap_group_member_assoc_attribute'] === 'memberUid')) p(' selected'); ?>>memberUid</option><option value="member"<?php if (isset($_['ldap_group_member_assoc_attribute']) && ($_['ldap_group_member_assoc_attribute'] === 'member')) p(' selected'); ?>>member (AD)</option><option value="gidNumber"<?php if (isset($_['ldap_group_member_assoc_attribute']) && ($_['ldap_group_member_assoc_attribute'] === 'gidNumber')) p(' selected'); ?>>gidNumber</option></select></p> <p><label for="ldap_dynamic_group_member_url"><?php p($l->t('Dynamic Group Member URL')); ?></label><input type="text" id="ldap_dynamic_group_member_url" name="ldap_dynamic_group_member_url" title="<?php p($l->t('The LDAP attribute that on group objects contains an LDAP search URL that determines what objects belong to the group. (An empty setting disables dynamic group membership functionality.)')); ?>" data-default="<?php p($_['ldap_dynamic_group_member_url_default']); ?>" /></p> |
|
99 | + <p><label for="ldap_nested_groups"><?php p($l->t('Nested Groups')); ?></label><input type="checkbox" id="ldap_nested_groups" name="ldap_nested_groups" value="1" data-default="<?php p($_['ldap_nested_groups_default']); ?>" title="<?php p($l->t('When switched on, groups that contain groups are supported. (Only works if the group member attribute contains DNs.)')); ?>" /></p> |
|
100 | + <p><label for="ldap_paging_size"><?php p($l->t('Paging chunksize')); ?></label><input type="number" id="ldap_paging_size" name="ldap_paging_size" title="<?php p($l->t('Chunksize used for paged LDAP searches that may return bulky results like user or group enumeration. (Setting it 0 disables paged LDAP searches in those situations.)')); ?>" data-default="<?php p($_['ldap_paging_size_default']); ?>" /></p> |
|
101 | + <p><label for="ldap_turn_on_pwd_change"><?php p($l->t('Enable LDAP password changes per user')); ?></label><span class="inlinetable"><span class="tablerow left"><input type="checkbox" id="ldap_turn_on_pwd_change" name="ldap_turn_on_pwd_change" value="1" data-default="<?php p($_['ldap_turn_on_pwd_change_default']); ?>" title="<?php p($l->t('Allow LDAP users to change their password and allow Super Administrators and Group Administrators to change the password of their LDAP users. Only works when access control policies are configured accordingly on the LDAP server. As passwords are sent in plaintext to the LDAP server, transport encryption must be used and password hashing should be configured on the LDAP server.')); ?>" /><span class="tablecell"><?php p($l->t('(New password is sent as plain text to LDAP)')); ?></span></span> |
|
102 | 102 | </span><br/></p> |
103 | - <p><label for="ldap_default_ppolicy_dn"><?php p($l->t('Default password policy DN'));?></label><input type="text" id="ldap_default_ppolicy_dn" name="ldap_default_ppolicy_dn" title="<?php p($l->t('The DN of a default password policy that will be used for password expiry handling. Works only when LDAP password changes per user are enabled and is only supported by OpenLDAP. Leave empty to disable password expiry handling.'));?>" data-default="<?php p($_['ldap_default_ppolicy_dn_default']); ?>" /></p> |
|
103 | + <p><label for="ldap_default_ppolicy_dn"><?php p($l->t('Default password policy DN')); ?></label><input type="text" id="ldap_default_ppolicy_dn" name="ldap_default_ppolicy_dn" title="<?php p($l->t('The DN of a default password policy that will be used for password expiry handling. Works only when LDAP password changes per user are enabled and is only supported by OpenLDAP. Leave empty to disable password expiry handling.')); ?>" data-default="<?php p($_['ldap_default_ppolicy_dn_default']); ?>" /></p> |
|
104 | 104 | </div> |
105 | - <h3><?php p($l->t('Special Attributes'));?></h3> |
|
105 | + <h3><?php p($l->t('Special Attributes')); ?></h3> |
|
106 | 106 | <div> |
107 | - <p><label for="ldap_quota_attr"><?php p($l->t('Quota Field'));?></label><input type="text" id="ldap_quota_attr" name="ldap_quota_attr" data-default="<?php p($_['ldap_quota_attr_default']); ?>" title="<?php p($l->t('Leave empty for user\'s default quota. Otherwise, specify an LDAP/AD attribute.'));?>" /></p> |
|
108 | - <p><label for="ldap_quota_def"><?php p($l->t('Quota Default'));?></label><input type="text" id="ldap_quota_def" name="ldap_quota_def" data-default="<?php p($_['ldap_quota_def_default']); ?>" title="<?php p($l->t('Override default quota for LDAP users who do not have a quota set in the Quota Field.'));?>" /></p> |
|
109 | - <p><label for="ldap_email_attr"><?php p($l->t('Email Field'));?></label><input type="text" id="ldap_email_attr" name="ldap_email_attr" data-default="<?php p($_['ldap_email_attr_default']); ?>" title="<?php p($l->t('Set the user\'s email from their LDAP attribute. Leave it empty for default behaviour.'));?>" /></p> |
|
110 | - <p><label for="home_folder_naming_rule"><?php p($l->t('User Home Folder Naming Rule'));?></label><input type="text" id="home_folder_naming_rule" name="home_folder_naming_rule" title="<?php p($l->t('Leave empty for user name (default). Otherwise, specify an LDAP/AD attribute.'));?>" data-default="<?php p($_['home_folder_naming_rule_default']); ?>" /></p> |
|
107 | + <p><label for="ldap_quota_attr"><?php p($l->t('Quota Field')); ?></label><input type="text" id="ldap_quota_attr" name="ldap_quota_attr" data-default="<?php p($_['ldap_quota_attr_default']); ?>" title="<?php p($l->t('Leave empty for user\'s default quota. Otherwise, specify an LDAP/AD attribute.')); ?>" /></p> |
|
108 | + <p><label for="ldap_quota_def"><?php p($l->t('Quota Default')); ?></label><input type="text" id="ldap_quota_def" name="ldap_quota_def" data-default="<?php p($_['ldap_quota_def_default']); ?>" title="<?php p($l->t('Override default quota for LDAP users who do not have a quota set in the Quota Field.')); ?>" /></p> |
|
109 | + <p><label for="ldap_email_attr"><?php p($l->t('Email Field')); ?></label><input type="text" id="ldap_email_attr" name="ldap_email_attr" data-default="<?php p($_['ldap_email_attr_default']); ?>" title="<?php p($l->t('Set the user\'s email from their LDAP attribute. Leave it empty for default behaviour.')); ?>" /></p> |
|
110 | + <p><label for="home_folder_naming_rule"><?php p($l->t('User Home Folder Naming Rule')); ?></label><input type="text" id="home_folder_naming_rule" name="home_folder_naming_rule" title="<?php p($l->t('Leave empty for user name (default). Otherwise, specify an LDAP/AD attribute.')); ?>" data-default="<?php p($_['home_folder_naming_rule_default']); ?>" /></p> |
|
111 | 111 | <p><label for="ldap_ext_storage_home_attribute"> <?php p($l->t('"$home" Placeholder Field')); ?></label><input type="text" id="ldap_ext_storage_home_attribute" name="ldap_ext_storage_home_attribute" title="<?php p($l->t('$home in an external storage configuration will be replaced with the value of the specified attribute')); ?>" data-default="<?php p($_['ldap_ext_storage_home_attribute_default']); ?>"></p> |
112 | 112 | </div> |
113 | 113 | </div> |
114 | 114 | <?php print_unescaped($_['settingControls']); ?> |
115 | 115 | </fieldset> |
116 | 116 | <fieldset id="ldapSettings-2"> |
117 | - <p><strong><?php p($l->t('Internal Username'));?></strong></p> |
|
118 | - <p class="ldapIndent"><?php p($l->t('By default the internal username will be created from the UUID attribute. It makes sure that the username is unique and characters do not need to be converted. The internal username has the restriction that only these characters are allowed: [ a-zA-Z0-9_.@- ]. Other characters are replaced with their ASCII correspondence or simply omitted. On collisions a number will be added/increased. The internal username is used to identify a user internally. It is also the default name for the user home folder. It is also a part of remote URLs, for instance for all *DAV services. With this setting, the default behavior can be overridden. Leave it empty for default behavior. Changes will have effect only on newly mapped (added) LDAP users.'));?></p> |
|
119 | - <p class="ldapIndent"><label for="ldap_expert_username_attr"><?php p($l->t('Internal Username Attribute:'));?></label><input type="text" id="ldap_expert_username_attr" name="ldap_expert_username_attr" data-default="<?php p($_['ldap_expert_username_attr_default']); ?>" /></p> |
|
120 | - <p><strong><?php p($l->t('Override UUID detection'));?></strong></p> |
|
121 | - <p class="ldapIndent"><?php p($l->t('By default, the UUID attribute is automatically detected. The UUID attribute is used to doubtlessly identify LDAP users and groups. Also, the internal username will be created based on the UUID, if not specified otherwise above. You can override the setting and pass an attribute of your choice. You must make sure that the attribute of your choice can be fetched for both users and groups and it is unique. Leave it empty for default behavior. Changes will have effect only on newly mapped (added) LDAP users and groups.'));?></p> |
|
122 | - <p class="ldapIndent"><label for="ldap_expert_uuid_user_attr"><?php p($l->t('UUID Attribute for Users:'));?></label><input type="text" id="ldap_expert_uuid_user_attr" name="ldap_expert_uuid_user_attr" data-default="<?php p($_['ldap_expert_uuid_user_attr_default']); ?>" /></p> |
|
123 | - <p class="ldapIndent"><label for="ldap_expert_uuid_group_attr"><?php p($l->t('UUID Attribute for Groups:'));?></label><input type="text" id="ldap_expert_uuid_group_attr" name="ldap_expert_uuid_group_attr" data-default="<?php p($_['ldap_expert_uuid_group_attr_default']); ?>" /></p> |
|
124 | - <p><strong><?php p($l->t('Username-LDAP User Mapping'));?></strong></p> |
|
125 | - <p class="ldapIndent"><?php p($l->t('Usernames are used to store and assign metadata. In order to precisely identify and recognize users, each LDAP user will have an internal username. This requires a mapping from username to LDAP user. The created username is mapped to the UUID of the LDAP user. Additionally the DN is cached as well to reduce LDAP interaction, but it is not used for identification. If the DN changes, the changes will be found. The internal username is used all over. Clearing the mappings will have leftovers everywhere. Clearing the mappings is not configuration sensitive, it affects all LDAP configurations! Never clear the mappings in a production environment, only in a testing or experimental stage.'));?></p> |
|
126 | - <p class="ldapIndent"><button type="button" id="ldap_action_clear_user_mappings" name="ldap_action_clear_user_mappings"><?php p($l->t('Clear Username-LDAP User Mapping'));?></button><br/><button type="button" id="ldap_action_clear_group_mappings" name="ldap_action_clear_group_mappings"><?php p($l->t('Clear Groupname-LDAP Group Mapping'));?></button></p> |
|
117 | + <p><strong><?php p($l->t('Internal Username')); ?></strong></p> |
|
118 | + <p class="ldapIndent"><?php p($l->t('By default the internal username will be created from the UUID attribute. It makes sure that the username is unique and characters do not need to be converted. The internal username has the restriction that only these characters are allowed: [ a-zA-Z0-9_.@- ]. Other characters are replaced with their ASCII correspondence or simply omitted. On collisions a number will be added/increased. The internal username is used to identify a user internally. It is also the default name for the user home folder. It is also a part of remote URLs, for instance for all *DAV services. With this setting, the default behavior can be overridden. Leave it empty for default behavior. Changes will have effect only on newly mapped (added) LDAP users.')); ?></p> |
|
119 | + <p class="ldapIndent"><label for="ldap_expert_username_attr"><?php p($l->t('Internal Username Attribute:')); ?></label><input type="text" id="ldap_expert_username_attr" name="ldap_expert_username_attr" data-default="<?php p($_['ldap_expert_username_attr_default']); ?>" /></p> |
|
120 | + <p><strong><?php p($l->t('Override UUID detection')); ?></strong></p> |
|
121 | + <p class="ldapIndent"><?php p($l->t('By default, the UUID attribute is automatically detected. The UUID attribute is used to doubtlessly identify LDAP users and groups. Also, the internal username will be created based on the UUID, if not specified otherwise above. You can override the setting and pass an attribute of your choice. You must make sure that the attribute of your choice can be fetched for both users and groups and it is unique. Leave it empty for default behavior. Changes will have effect only on newly mapped (added) LDAP users and groups.')); ?></p> |
|
122 | + <p class="ldapIndent"><label for="ldap_expert_uuid_user_attr"><?php p($l->t('UUID Attribute for Users:')); ?></label><input type="text" id="ldap_expert_uuid_user_attr" name="ldap_expert_uuid_user_attr" data-default="<?php p($_['ldap_expert_uuid_user_attr_default']); ?>" /></p> |
|
123 | + <p class="ldapIndent"><label for="ldap_expert_uuid_group_attr"><?php p($l->t('UUID Attribute for Groups:')); ?></label><input type="text" id="ldap_expert_uuid_group_attr" name="ldap_expert_uuid_group_attr" data-default="<?php p($_['ldap_expert_uuid_group_attr_default']); ?>" /></p> |
|
124 | + <p><strong><?php p($l->t('Username-LDAP User Mapping')); ?></strong></p> |
|
125 | + <p class="ldapIndent"><?php p($l->t('Usernames are used to store and assign metadata. In order to precisely identify and recognize users, each LDAP user will have an internal username. This requires a mapping from username to LDAP user. The created username is mapped to the UUID of the LDAP user. Additionally the DN is cached as well to reduce LDAP interaction, but it is not used for identification. If the DN changes, the changes will be found. The internal username is used all over. Clearing the mappings will have leftovers everywhere. Clearing the mappings is not configuration sensitive, it affects all LDAP configurations! Never clear the mappings in a production environment, only in a testing or experimental stage.')); ?></p> |
|
126 | + <p class="ldapIndent"><button type="button" id="ldap_action_clear_user_mappings" name="ldap_action_clear_user_mappings"><?php p($l->t('Clear Username-LDAP User Mapping')); ?></button><br/><button type="button" id="ldap_action_clear_group_mappings" name="ldap_action_clear_group_mappings"><?php p($l->t('Clear Groupname-LDAP Group Mapping')); ?></button></p> |
|
127 | 127 | <?php print_unescaped($_['settingControls']); ?> |
128 | 128 | </fieldset> |
129 | 129 | </div> |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | $offset = $arguments['offset']; |
70 | 70 | $stopAt = $arguments['stopAt']; |
71 | 71 | |
72 | - $this->logger->info('Building calendar index (' . $offset .'/' . $stopAt . ')'); |
|
72 | + $this->logger->info('Building calendar index ('.$offset.'/'.$stopAt.')'); |
|
73 | 73 | |
74 | 74 | $offset = $this->buildIndex($offset, $stopAt); |
75 | 75 | |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | 'offset' => $offset, |
81 | 81 | 'stopAt' => $stopAt |
82 | 82 | ]); |
83 | - $this->logger->info('New building calendar index job scheduled with offset ' . $offset); |
|
83 | + $this->logger->info('New building calendar index job scheduled with offset '.$offset); |
|
84 | 84 | } |
85 | 85 | } |
86 | 86 | |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | ->orderBy('id', 'ASC'); |
101 | 101 | |
102 | 102 | $stmt = $query->execute(); |
103 | - while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { |
|
103 | + while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { |
|
104 | 104 | $offset = $row['id']; |
105 | 105 | |
106 | 106 | $calendarData = $row['calendardata']; |
@@ -31,90 +31,90 @@ |
||
31 | 31 | |
32 | 32 | class BuildCalendarSearchIndexBackgroundJob extends QueuedJob { |
33 | 33 | |
34 | - /** @var IDBConnection */ |
|
35 | - private $db; |
|
36 | - |
|
37 | - /** @var CalDavBackend */ |
|
38 | - private $calDavBackend; |
|
39 | - |
|
40 | - /** @var ILogger */ |
|
41 | - private $logger; |
|
42 | - |
|
43 | - /** @var IJobList */ |
|
44 | - private $jobList; |
|
45 | - |
|
46 | - /** @var ITimeFactory */ |
|
47 | - private $timeFactory; |
|
48 | - |
|
49 | - /** |
|
50 | - * @param IDBConnection $db |
|
51 | - * @param CalDavBackend $calDavBackend |
|
52 | - * @param ILogger $logger |
|
53 | - * @param IJobList $jobList |
|
54 | - * @param ITimeFactory $timeFactory |
|
55 | - */ |
|
56 | - public function __construct(IDBConnection $db, |
|
57 | - CalDavBackend $calDavBackend, |
|
58 | - ILogger $logger, |
|
59 | - IJobList $jobList, |
|
60 | - ITimeFactory $timeFactory) { |
|
61 | - $this->db = $db; |
|
62 | - $this->calDavBackend = $calDavBackend; |
|
63 | - $this->logger = $logger; |
|
64 | - $this->jobList = $jobList; |
|
65 | - $this->timeFactory = $timeFactory; |
|
66 | - } |
|
67 | - |
|
68 | - public function run($arguments) { |
|
69 | - $offset = $arguments['offset']; |
|
70 | - $stopAt = $arguments['stopAt']; |
|
71 | - |
|
72 | - $this->logger->info('Building calendar index (' . $offset .'/' . $stopAt . ')'); |
|
73 | - |
|
74 | - $offset = $this->buildIndex($offset, $stopAt); |
|
75 | - |
|
76 | - if ($offset >= $stopAt) { |
|
77 | - $this->logger->info('Building calendar index done'); |
|
78 | - } else { |
|
79 | - $this->jobList->add(self::class, [ |
|
80 | - 'offset' => $offset, |
|
81 | - 'stopAt' => $stopAt |
|
82 | - ]); |
|
83 | - $this->logger->info('New building calendar index job scheduled with offset ' . $offset); |
|
84 | - } |
|
85 | - } |
|
86 | - |
|
87 | - /** |
|
88 | - * @param int $offset |
|
89 | - * @param int $stopAt |
|
90 | - * @return int |
|
91 | - */ |
|
92 | - private function buildIndex($offset, $stopAt) { |
|
93 | - $startTime = $this->timeFactory->getTime(); |
|
94 | - |
|
95 | - $query = $this->db->getQueryBuilder(); |
|
96 | - $query->select(['id', 'calendarid', 'uri', 'calendardata']) |
|
97 | - ->from('calendarobjects') |
|
98 | - ->where($query->expr()->lte('id', $query->createNamedParameter($stopAt))) |
|
99 | - ->andWhere($query->expr()->gt('id', $query->createNamedParameter($offset))) |
|
100 | - ->orderBy('id', 'ASC'); |
|
101 | - |
|
102 | - $stmt = $query->execute(); |
|
103 | - while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { |
|
104 | - $offset = $row['id']; |
|
105 | - |
|
106 | - $calendarData = $row['calendardata']; |
|
107 | - if (is_resource($calendarData)) { |
|
108 | - $calendarData = stream_get_contents($calendarData); |
|
109 | - } |
|
110 | - |
|
111 | - $this->calDavBackend->updateProperties($row['calendarid'], $row['uri'], $calendarData); |
|
112 | - |
|
113 | - if (($this->timeFactory->getTime() - $startTime) > 15) { |
|
114 | - return $offset; |
|
115 | - } |
|
116 | - } |
|
117 | - |
|
118 | - return $stopAt; |
|
119 | - } |
|
34 | + /** @var IDBConnection */ |
|
35 | + private $db; |
|
36 | + |
|
37 | + /** @var CalDavBackend */ |
|
38 | + private $calDavBackend; |
|
39 | + |
|
40 | + /** @var ILogger */ |
|
41 | + private $logger; |
|
42 | + |
|
43 | + /** @var IJobList */ |
|
44 | + private $jobList; |
|
45 | + |
|
46 | + /** @var ITimeFactory */ |
|
47 | + private $timeFactory; |
|
48 | + |
|
49 | + /** |
|
50 | + * @param IDBConnection $db |
|
51 | + * @param CalDavBackend $calDavBackend |
|
52 | + * @param ILogger $logger |
|
53 | + * @param IJobList $jobList |
|
54 | + * @param ITimeFactory $timeFactory |
|
55 | + */ |
|
56 | + public function __construct(IDBConnection $db, |
|
57 | + CalDavBackend $calDavBackend, |
|
58 | + ILogger $logger, |
|
59 | + IJobList $jobList, |
|
60 | + ITimeFactory $timeFactory) { |
|
61 | + $this->db = $db; |
|
62 | + $this->calDavBackend = $calDavBackend; |
|
63 | + $this->logger = $logger; |
|
64 | + $this->jobList = $jobList; |
|
65 | + $this->timeFactory = $timeFactory; |
|
66 | + } |
|
67 | + |
|
68 | + public function run($arguments) { |
|
69 | + $offset = $arguments['offset']; |
|
70 | + $stopAt = $arguments['stopAt']; |
|
71 | + |
|
72 | + $this->logger->info('Building calendar index (' . $offset .'/' . $stopAt . ')'); |
|
73 | + |
|
74 | + $offset = $this->buildIndex($offset, $stopAt); |
|
75 | + |
|
76 | + if ($offset >= $stopAt) { |
|
77 | + $this->logger->info('Building calendar index done'); |
|
78 | + } else { |
|
79 | + $this->jobList->add(self::class, [ |
|
80 | + 'offset' => $offset, |
|
81 | + 'stopAt' => $stopAt |
|
82 | + ]); |
|
83 | + $this->logger->info('New building calendar index job scheduled with offset ' . $offset); |
|
84 | + } |
|
85 | + } |
|
86 | + |
|
87 | + /** |
|
88 | + * @param int $offset |
|
89 | + * @param int $stopAt |
|
90 | + * @return int |
|
91 | + */ |
|
92 | + private function buildIndex($offset, $stopAt) { |
|
93 | + $startTime = $this->timeFactory->getTime(); |
|
94 | + |
|
95 | + $query = $this->db->getQueryBuilder(); |
|
96 | + $query->select(['id', 'calendarid', 'uri', 'calendardata']) |
|
97 | + ->from('calendarobjects') |
|
98 | + ->where($query->expr()->lte('id', $query->createNamedParameter($stopAt))) |
|
99 | + ->andWhere($query->expr()->gt('id', $query->createNamedParameter($offset))) |
|
100 | + ->orderBy('id', 'ASC'); |
|
101 | + |
|
102 | + $stmt = $query->execute(); |
|
103 | + while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { |
|
104 | + $offset = $row['id']; |
|
105 | + |
|
106 | + $calendarData = $row['calendardata']; |
|
107 | + if (is_resource($calendarData)) { |
|
108 | + $calendarData = stream_get_contents($calendarData); |
|
109 | + } |
|
110 | + |
|
111 | + $this->calDavBackend->updateProperties($row['calendarid'], $row['uri'], $calendarData); |
|
112 | + |
|
113 | + if (($this->timeFactory->getTime() - $startTime) > 15) { |
|
114 | + return $offset; |
|
115 | + } |
|
116 | + } |
|
117 | + |
|
118 | + return $stopAt; |
|
119 | + } |
|
120 | 120 | } |