@@ -25,7 +25,7 @@ |
||
25 | 25 | use OCP\AppFramework\Http; |
26 | 26 | |
27 | 27 | class RateLimitExceededException extends SecurityException { |
28 | - public function __construct() { |
|
29 | - parent::__construct('Rate limit exceeded', Http::STATUS_TOO_MANY_REQUESTS); |
|
30 | - } |
|
28 | + public function __construct() { |
|
29 | + parent::__construct('Rate limit exceeded', Http::STATUS_TOO_MANY_REQUESTS); |
|
30 | + } |
|
31 | 31 | } |
@@ -48,87 +48,87 @@ |
||
48 | 48 | * @package OC\AppFramework\Middleware\Security |
49 | 49 | */ |
50 | 50 | class RateLimitingMiddleware extends Middleware { |
51 | - /** @var IRequest $request */ |
|
52 | - private $request; |
|
53 | - /** @var IUserSession */ |
|
54 | - private $userSession; |
|
55 | - /** @var ControllerMethodReflector */ |
|
56 | - private $reflector; |
|
57 | - /** @var Limiter */ |
|
58 | - private $limiter; |
|
51 | + /** @var IRequest $request */ |
|
52 | + private $request; |
|
53 | + /** @var IUserSession */ |
|
54 | + private $userSession; |
|
55 | + /** @var ControllerMethodReflector */ |
|
56 | + private $reflector; |
|
57 | + /** @var Limiter */ |
|
58 | + private $limiter; |
|
59 | 59 | |
60 | - /** |
|
61 | - * @param IRequest $request |
|
62 | - * @param IUserSession $userSession |
|
63 | - * @param ControllerMethodReflector $reflector |
|
64 | - * @param Limiter $limiter |
|
65 | - */ |
|
66 | - public function __construct(IRequest $request, |
|
67 | - IUserSession $userSession, |
|
68 | - ControllerMethodReflector $reflector, |
|
69 | - Limiter $limiter) { |
|
70 | - $this->request = $request; |
|
71 | - $this->userSession = $userSession; |
|
72 | - $this->reflector = $reflector; |
|
73 | - $this->limiter = $limiter; |
|
74 | - } |
|
60 | + /** |
|
61 | + * @param IRequest $request |
|
62 | + * @param IUserSession $userSession |
|
63 | + * @param ControllerMethodReflector $reflector |
|
64 | + * @param Limiter $limiter |
|
65 | + */ |
|
66 | + public function __construct(IRequest $request, |
|
67 | + IUserSession $userSession, |
|
68 | + ControllerMethodReflector $reflector, |
|
69 | + Limiter $limiter) { |
|
70 | + $this->request = $request; |
|
71 | + $this->userSession = $userSession; |
|
72 | + $this->reflector = $reflector; |
|
73 | + $this->limiter = $limiter; |
|
74 | + } |
|
75 | 75 | |
76 | - /** |
|
77 | - * {@inheritDoc} |
|
78 | - * @throws RateLimitExceededException |
|
79 | - */ |
|
80 | - public function beforeController($controller, $methodName) { |
|
81 | - parent::beforeController($controller, $methodName); |
|
76 | + /** |
|
77 | + * {@inheritDoc} |
|
78 | + * @throws RateLimitExceededException |
|
79 | + */ |
|
80 | + public function beforeController($controller, $methodName) { |
|
81 | + parent::beforeController($controller, $methodName); |
|
82 | 82 | |
83 | - $anonLimit = $this->reflector->getAnnotationParameter('AnonRateThrottle', 'limit'); |
|
84 | - $anonPeriod = $this->reflector->getAnnotationParameter('AnonRateThrottle', 'period'); |
|
85 | - $userLimit = $this->reflector->getAnnotationParameter('UserRateThrottle', 'limit'); |
|
86 | - $userPeriod = $this->reflector->getAnnotationParameter('UserRateThrottle', 'period'); |
|
87 | - $rateLimitIdentifier = get_class($controller) . '::' . $methodName; |
|
88 | - if($userLimit !== '' && $userPeriod !== '' && $this->userSession->isLoggedIn()) { |
|
89 | - $this->limiter->registerUserRequest( |
|
90 | - $rateLimitIdentifier, |
|
91 | - $userLimit, |
|
92 | - $userPeriod, |
|
93 | - $this->userSession->getUser() |
|
94 | - ); |
|
95 | - } elseif ($anonLimit !== '' && $anonPeriod !== '') { |
|
96 | - $this->limiter->registerAnonRequest( |
|
97 | - $rateLimitIdentifier, |
|
98 | - $anonLimit, |
|
99 | - $anonPeriod, |
|
100 | - $this->request->getRemoteAddress() |
|
101 | - ); |
|
102 | - } |
|
103 | - } |
|
83 | + $anonLimit = $this->reflector->getAnnotationParameter('AnonRateThrottle', 'limit'); |
|
84 | + $anonPeriod = $this->reflector->getAnnotationParameter('AnonRateThrottle', 'period'); |
|
85 | + $userLimit = $this->reflector->getAnnotationParameter('UserRateThrottle', 'limit'); |
|
86 | + $userPeriod = $this->reflector->getAnnotationParameter('UserRateThrottle', 'period'); |
|
87 | + $rateLimitIdentifier = get_class($controller) . '::' . $methodName; |
|
88 | + if($userLimit !== '' && $userPeriod !== '' && $this->userSession->isLoggedIn()) { |
|
89 | + $this->limiter->registerUserRequest( |
|
90 | + $rateLimitIdentifier, |
|
91 | + $userLimit, |
|
92 | + $userPeriod, |
|
93 | + $this->userSession->getUser() |
|
94 | + ); |
|
95 | + } elseif ($anonLimit !== '' && $anonPeriod !== '') { |
|
96 | + $this->limiter->registerAnonRequest( |
|
97 | + $rateLimitIdentifier, |
|
98 | + $anonLimit, |
|
99 | + $anonPeriod, |
|
100 | + $this->request->getRemoteAddress() |
|
101 | + ); |
|
102 | + } |
|
103 | + } |
|
104 | 104 | |
105 | - /** |
|
106 | - * {@inheritDoc} |
|
107 | - */ |
|
108 | - public function afterException($controller, $methodName, \Exception $exception) { |
|
109 | - if($exception instanceof RateLimitExceededException) { |
|
110 | - if (stripos($this->request->getHeader('Accept'),'html') === false) { |
|
111 | - $response = new JSONResponse( |
|
112 | - [ |
|
113 | - 'message' => $exception->getMessage(), |
|
114 | - ], |
|
115 | - $exception->getCode() |
|
116 | - ); |
|
117 | - } else { |
|
118 | - $response = new TemplateResponse( |
|
119 | - 'core', |
|
120 | - '403', |
|
121 | - [ |
|
122 | - 'file' => $exception->getMessage() |
|
123 | - ], |
|
124 | - 'guest' |
|
125 | - ); |
|
126 | - $response->setStatus($exception->getCode()); |
|
127 | - } |
|
105 | + /** |
|
106 | + * {@inheritDoc} |
|
107 | + */ |
|
108 | + public function afterException($controller, $methodName, \Exception $exception) { |
|
109 | + if($exception instanceof RateLimitExceededException) { |
|
110 | + if (stripos($this->request->getHeader('Accept'),'html') === false) { |
|
111 | + $response = new JSONResponse( |
|
112 | + [ |
|
113 | + 'message' => $exception->getMessage(), |
|
114 | + ], |
|
115 | + $exception->getCode() |
|
116 | + ); |
|
117 | + } else { |
|
118 | + $response = new TemplateResponse( |
|
119 | + 'core', |
|
120 | + '403', |
|
121 | + [ |
|
122 | + 'file' => $exception->getMessage() |
|
123 | + ], |
|
124 | + 'guest' |
|
125 | + ); |
|
126 | + $response->setStatus($exception->getCode()); |
|
127 | + } |
|
128 | 128 | |
129 | - return $response; |
|
130 | - } |
|
129 | + return $response; |
|
130 | + } |
|
131 | 131 | |
132 | - throw $exception; |
|
133 | - } |
|
132 | + throw $exception; |
|
133 | + } |
|
134 | 134 | } |
@@ -84,8 +84,8 @@ discard block |
||
84 | 84 | $anonPeriod = $this->reflector->getAnnotationParameter('AnonRateThrottle', 'period'); |
85 | 85 | $userLimit = $this->reflector->getAnnotationParameter('UserRateThrottle', 'limit'); |
86 | 86 | $userPeriod = $this->reflector->getAnnotationParameter('UserRateThrottle', 'period'); |
87 | - $rateLimitIdentifier = get_class($controller) . '::' . $methodName; |
|
88 | - if($userLimit !== '' && $userPeriod !== '' && $this->userSession->isLoggedIn()) { |
|
87 | + $rateLimitIdentifier = get_class($controller).'::'.$methodName; |
|
88 | + if ($userLimit !== '' && $userPeriod !== '' && $this->userSession->isLoggedIn()) { |
|
89 | 89 | $this->limiter->registerUserRequest( |
90 | 90 | $rateLimitIdentifier, |
91 | 91 | $userLimit, |
@@ -106,8 +106,8 @@ discard block |
||
106 | 106 | * {@inheritDoc} |
107 | 107 | */ |
108 | 108 | public function afterException($controller, $methodName, \Exception $exception) { |
109 | - if($exception instanceof RateLimitExceededException) { |
|
110 | - if (stripos($this->request->getHeader('Accept'),'html') === false) { |
|
109 | + if ($exception instanceof RateLimitExceededException) { |
|
110 | + if (stripos($this->request->getHeader('Accept'), 'html') === false) { |
|
111 | 111 | $response = new JSONResponse( |
112 | 112 | [ |
113 | 113 | 'message' => $exception->getMessage(), |
@@ -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 | } |
@@ -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 | ); |
@@ -44,185 +44,185 @@ |
||
44 | 44 | * User storages controller |
45 | 45 | */ |
46 | 46 | class UserStoragesController extends StoragesController { |
47 | - /** |
|
48 | - * @var IUserSession |
|
49 | - */ |
|
50 | - private $userSession; |
|
51 | - |
|
52 | - /** |
|
53 | - * Creates a new user storages controller. |
|
54 | - * |
|
55 | - * @param string $AppName application name |
|
56 | - * @param IRequest $request request object |
|
57 | - * @param IL10N $l10n l10n service |
|
58 | - * @param UserStoragesService $userStoragesService storage service |
|
59 | - * @param IUserSession $userSession |
|
60 | - * @param ILogger $logger |
|
61 | - */ |
|
62 | - public function __construct( |
|
63 | - $AppName, |
|
64 | - IRequest $request, |
|
65 | - IL10N $l10n, |
|
66 | - UserStoragesService $userStoragesService, |
|
67 | - IUserSession $userSession, |
|
68 | - ILogger $logger |
|
69 | - ) { |
|
70 | - parent::__construct( |
|
71 | - $AppName, |
|
72 | - $request, |
|
73 | - $l10n, |
|
74 | - $userStoragesService, |
|
75 | - $logger |
|
76 | - ); |
|
77 | - $this->userSession = $userSession; |
|
78 | - } |
|
79 | - |
|
80 | - protected function manipulateStorageConfig(StorageConfig $storage) { |
|
81 | - /** @var AuthMechanism */ |
|
82 | - $authMechanism = $storage->getAuthMechanism(); |
|
83 | - $authMechanism->manipulateStorageConfig($storage, $this->userSession->getUser()); |
|
84 | - /** @var Backend */ |
|
85 | - $backend = $storage->getBackend(); |
|
86 | - $backend->manipulateStorageConfig($storage, $this->userSession->getUser()); |
|
87 | - } |
|
88 | - |
|
89 | - /** |
|
90 | - * Get all storage entries |
|
91 | - * |
|
92 | - * @NoAdminRequired |
|
93 | - * |
|
94 | - * @return DataResponse |
|
95 | - */ |
|
96 | - public function index() { |
|
97 | - return parent::index(); |
|
98 | - } |
|
99 | - |
|
100 | - /** |
|
101 | - * Return storage |
|
102 | - * |
|
103 | - * @NoAdminRequired |
|
104 | - * |
|
105 | - * {@inheritdoc} |
|
106 | - */ |
|
107 | - public function show($id, $testOnly = true) { |
|
108 | - return parent::show($id, $testOnly); |
|
109 | - } |
|
110 | - |
|
111 | - /** |
|
112 | - * Create an external storage entry. |
|
113 | - * |
|
114 | - * @param string $mountPoint storage mount point |
|
115 | - * @param string $backend backend identifier |
|
116 | - * @param string $authMechanism authentication mechanism identifier |
|
117 | - * @param array $backendOptions backend-specific options |
|
118 | - * @param array $mountOptions backend-specific mount options |
|
119 | - * |
|
120 | - * @return DataResponse |
|
121 | - * |
|
122 | - * @NoAdminRequired |
|
123 | - */ |
|
124 | - public function create( |
|
125 | - $mountPoint, |
|
126 | - $backend, |
|
127 | - $authMechanism, |
|
128 | - $backendOptions, |
|
129 | - $mountOptions |
|
130 | - ) { |
|
131 | - $newStorage = $this->createStorage( |
|
132 | - $mountPoint, |
|
133 | - $backend, |
|
134 | - $authMechanism, |
|
135 | - $backendOptions, |
|
136 | - $mountOptions |
|
137 | - ); |
|
138 | - if ($newStorage instanceOf DataResponse) { |
|
139 | - return $newStorage; |
|
140 | - } |
|
141 | - |
|
142 | - $response = $this->validate($newStorage); |
|
143 | - if (!empty($response)) { |
|
144 | - return $response; |
|
145 | - } |
|
146 | - |
|
147 | - $newStorage = $this->service->addStorage($newStorage); |
|
148 | - $this->updateStorageStatus($newStorage); |
|
149 | - |
|
150 | - return new DataResponse( |
|
151 | - $this->formatStorageForUI($newStorage), |
|
152 | - Http::STATUS_CREATED |
|
153 | - ); |
|
154 | - } |
|
155 | - |
|
156 | - /** |
|
157 | - * Update an external storage entry. |
|
158 | - * |
|
159 | - * @param int $id storage id |
|
160 | - * @param string $mountPoint storage mount point |
|
161 | - * @param string $backend backend identifier |
|
162 | - * @param string $authMechanism authentication mechanism identifier |
|
163 | - * @param array $backendOptions backend-specific options |
|
164 | - * @param array $mountOptions backend-specific mount options |
|
165 | - * @param bool $testOnly whether to storage should only test the connection or do more things |
|
166 | - * |
|
167 | - * @return DataResponse |
|
168 | - * |
|
169 | - * @NoAdminRequired |
|
170 | - */ |
|
171 | - public function update( |
|
172 | - $id, |
|
173 | - $mountPoint, |
|
174 | - $backend, |
|
175 | - $authMechanism, |
|
176 | - $backendOptions, |
|
177 | - $mountOptions, |
|
178 | - $testOnly = true |
|
179 | - ) { |
|
180 | - $storage = $this->createStorage( |
|
181 | - $mountPoint, |
|
182 | - $backend, |
|
183 | - $authMechanism, |
|
184 | - $backendOptions, |
|
185 | - $mountOptions |
|
186 | - ); |
|
187 | - if ($storage instanceOf DataResponse) { |
|
188 | - return $storage; |
|
189 | - } |
|
190 | - $storage->setId($id); |
|
191 | - |
|
192 | - $response = $this->validate($storage); |
|
193 | - if (!empty($response)) { |
|
194 | - return $response; |
|
195 | - } |
|
196 | - |
|
197 | - try { |
|
198 | - $storage = $this->service->updateStorage($storage); |
|
199 | - } catch (NotFoundException $e) { |
|
200 | - return new DataResponse( |
|
201 | - [ |
|
202 | - 'message' => (string)$this->l10n->t('Storage with ID "%d" not found', array($id)) |
|
203 | - ], |
|
204 | - Http::STATUS_NOT_FOUND |
|
205 | - ); |
|
206 | - } |
|
207 | - |
|
208 | - $this->updateStorageStatus($storage, $testOnly); |
|
209 | - |
|
210 | - return new DataResponse( |
|
211 | - $this->formatStorageForUI($storage), |
|
212 | - Http::STATUS_OK |
|
213 | - ); |
|
214 | - |
|
215 | - } |
|
216 | - |
|
217 | - /** |
|
218 | - * Delete storage |
|
219 | - * |
|
220 | - * @NoAdminRequired |
|
221 | - * |
|
222 | - * {@inheritdoc} |
|
223 | - */ |
|
224 | - public function destroy($id) { |
|
225 | - return parent::destroy($id); |
|
226 | - } |
|
47 | + /** |
|
48 | + * @var IUserSession |
|
49 | + */ |
|
50 | + private $userSession; |
|
51 | + |
|
52 | + /** |
|
53 | + * Creates a new user storages controller. |
|
54 | + * |
|
55 | + * @param string $AppName application name |
|
56 | + * @param IRequest $request request object |
|
57 | + * @param IL10N $l10n l10n service |
|
58 | + * @param UserStoragesService $userStoragesService storage service |
|
59 | + * @param IUserSession $userSession |
|
60 | + * @param ILogger $logger |
|
61 | + */ |
|
62 | + public function __construct( |
|
63 | + $AppName, |
|
64 | + IRequest $request, |
|
65 | + IL10N $l10n, |
|
66 | + UserStoragesService $userStoragesService, |
|
67 | + IUserSession $userSession, |
|
68 | + ILogger $logger |
|
69 | + ) { |
|
70 | + parent::__construct( |
|
71 | + $AppName, |
|
72 | + $request, |
|
73 | + $l10n, |
|
74 | + $userStoragesService, |
|
75 | + $logger |
|
76 | + ); |
|
77 | + $this->userSession = $userSession; |
|
78 | + } |
|
79 | + |
|
80 | + protected function manipulateStorageConfig(StorageConfig $storage) { |
|
81 | + /** @var AuthMechanism */ |
|
82 | + $authMechanism = $storage->getAuthMechanism(); |
|
83 | + $authMechanism->manipulateStorageConfig($storage, $this->userSession->getUser()); |
|
84 | + /** @var Backend */ |
|
85 | + $backend = $storage->getBackend(); |
|
86 | + $backend->manipulateStorageConfig($storage, $this->userSession->getUser()); |
|
87 | + } |
|
88 | + |
|
89 | + /** |
|
90 | + * Get all storage entries |
|
91 | + * |
|
92 | + * @NoAdminRequired |
|
93 | + * |
|
94 | + * @return DataResponse |
|
95 | + */ |
|
96 | + public function index() { |
|
97 | + return parent::index(); |
|
98 | + } |
|
99 | + |
|
100 | + /** |
|
101 | + * Return storage |
|
102 | + * |
|
103 | + * @NoAdminRequired |
|
104 | + * |
|
105 | + * {@inheritdoc} |
|
106 | + */ |
|
107 | + public function show($id, $testOnly = true) { |
|
108 | + return parent::show($id, $testOnly); |
|
109 | + } |
|
110 | + |
|
111 | + /** |
|
112 | + * Create an external storage entry. |
|
113 | + * |
|
114 | + * @param string $mountPoint storage mount point |
|
115 | + * @param string $backend backend identifier |
|
116 | + * @param string $authMechanism authentication mechanism identifier |
|
117 | + * @param array $backendOptions backend-specific options |
|
118 | + * @param array $mountOptions backend-specific mount options |
|
119 | + * |
|
120 | + * @return DataResponse |
|
121 | + * |
|
122 | + * @NoAdminRequired |
|
123 | + */ |
|
124 | + public function create( |
|
125 | + $mountPoint, |
|
126 | + $backend, |
|
127 | + $authMechanism, |
|
128 | + $backendOptions, |
|
129 | + $mountOptions |
|
130 | + ) { |
|
131 | + $newStorage = $this->createStorage( |
|
132 | + $mountPoint, |
|
133 | + $backend, |
|
134 | + $authMechanism, |
|
135 | + $backendOptions, |
|
136 | + $mountOptions |
|
137 | + ); |
|
138 | + if ($newStorage instanceOf DataResponse) { |
|
139 | + return $newStorage; |
|
140 | + } |
|
141 | + |
|
142 | + $response = $this->validate($newStorage); |
|
143 | + if (!empty($response)) { |
|
144 | + return $response; |
|
145 | + } |
|
146 | + |
|
147 | + $newStorage = $this->service->addStorage($newStorage); |
|
148 | + $this->updateStorageStatus($newStorage); |
|
149 | + |
|
150 | + return new DataResponse( |
|
151 | + $this->formatStorageForUI($newStorage), |
|
152 | + Http::STATUS_CREATED |
|
153 | + ); |
|
154 | + } |
|
155 | + |
|
156 | + /** |
|
157 | + * Update an external storage entry. |
|
158 | + * |
|
159 | + * @param int $id storage id |
|
160 | + * @param string $mountPoint storage mount point |
|
161 | + * @param string $backend backend identifier |
|
162 | + * @param string $authMechanism authentication mechanism identifier |
|
163 | + * @param array $backendOptions backend-specific options |
|
164 | + * @param array $mountOptions backend-specific mount options |
|
165 | + * @param bool $testOnly whether to storage should only test the connection or do more things |
|
166 | + * |
|
167 | + * @return DataResponse |
|
168 | + * |
|
169 | + * @NoAdminRequired |
|
170 | + */ |
|
171 | + public function update( |
|
172 | + $id, |
|
173 | + $mountPoint, |
|
174 | + $backend, |
|
175 | + $authMechanism, |
|
176 | + $backendOptions, |
|
177 | + $mountOptions, |
|
178 | + $testOnly = true |
|
179 | + ) { |
|
180 | + $storage = $this->createStorage( |
|
181 | + $mountPoint, |
|
182 | + $backend, |
|
183 | + $authMechanism, |
|
184 | + $backendOptions, |
|
185 | + $mountOptions |
|
186 | + ); |
|
187 | + if ($storage instanceOf DataResponse) { |
|
188 | + return $storage; |
|
189 | + } |
|
190 | + $storage->setId($id); |
|
191 | + |
|
192 | + $response = $this->validate($storage); |
|
193 | + if (!empty($response)) { |
|
194 | + return $response; |
|
195 | + } |
|
196 | + |
|
197 | + try { |
|
198 | + $storage = $this->service->updateStorage($storage); |
|
199 | + } catch (NotFoundException $e) { |
|
200 | + return new DataResponse( |
|
201 | + [ |
|
202 | + 'message' => (string)$this->l10n->t('Storage with ID "%d" not found', array($id)) |
|
203 | + ], |
|
204 | + Http::STATUS_NOT_FOUND |
|
205 | + ); |
|
206 | + } |
|
207 | + |
|
208 | + $this->updateStorageStatus($storage, $testOnly); |
|
209 | + |
|
210 | + return new DataResponse( |
|
211 | + $this->formatStorageForUI($storage), |
|
212 | + Http::STATUS_OK |
|
213 | + ); |
|
214 | + |
|
215 | + } |
|
216 | + |
|
217 | + /** |
|
218 | + * Delete storage |
|
219 | + * |
|
220 | + * @NoAdminRequired |
|
221 | + * |
|
222 | + * {@inheritdoc} |
|
223 | + */ |
|
224 | + public function destroy($id) { |
|
225 | + return parent::destroy($id); |
|
226 | + } |
|
227 | 227 | |
228 | 228 | } |
@@ -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 | ); |
@@ -45,165 +45,165 @@ |
||
45 | 45 | * User global storages controller |
46 | 46 | */ |
47 | 47 | class UserGlobalStoragesController extends StoragesController { |
48 | - /** |
|
49 | - * @var IUserSession |
|
50 | - */ |
|
51 | - private $userSession; |
|
52 | - |
|
53 | - /** |
|
54 | - * Creates a new user global storages controller. |
|
55 | - * |
|
56 | - * @param string $AppName application name |
|
57 | - * @param IRequest $request request object |
|
58 | - * @param IL10N $l10n l10n service |
|
59 | - * @param UserGlobalStoragesService $userGlobalStoragesService storage service |
|
60 | - * @param IUserSession $userSession |
|
61 | - */ |
|
62 | - public function __construct( |
|
63 | - $AppName, |
|
64 | - IRequest $request, |
|
65 | - IL10N $l10n, |
|
66 | - UserGlobalStoragesService $userGlobalStoragesService, |
|
67 | - IUserSession $userSession, |
|
68 | - ILogger $logger |
|
69 | - ) { |
|
70 | - parent::__construct( |
|
71 | - $AppName, |
|
72 | - $request, |
|
73 | - $l10n, |
|
74 | - $userGlobalStoragesService, |
|
75 | - $logger |
|
76 | - ); |
|
77 | - $this->userSession = $userSession; |
|
78 | - } |
|
79 | - |
|
80 | - /** |
|
81 | - * Get all storage entries |
|
82 | - * |
|
83 | - * @return DataResponse |
|
84 | - * |
|
85 | - * @NoAdminRequired |
|
86 | - */ |
|
87 | - public function index() { |
|
88 | - $storages = $this->formatStoragesForUI($this->service->getUniqueStorages()); |
|
89 | - |
|
90 | - // remove configuration data, this must be kept private |
|
91 | - foreach ($storages as $storage) { |
|
92 | - $this->sanitizeStorage($storage); |
|
93 | - } |
|
94 | - |
|
95 | - return new DataResponse( |
|
96 | - $storages, |
|
97 | - Http::STATUS_OK |
|
98 | - ); |
|
99 | - } |
|
100 | - |
|
101 | - protected function manipulateStorageConfig(StorageConfig $storage) { |
|
102 | - /** @var AuthMechanism */ |
|
103 | - $authMechanism = $storage->getAuthMechanism(); |
|
104 | - $authMechanism->manipulateStorageConfig($storage, $this->userSession->getUser()); |
|
105 | - /** @var Backend */ |
|
106 | - $backend = $storage->getBackend(); |
|
107 | - $backend->manipulateStorageConfig($storage, $this->userSession->getUser()); |
|
108 | - } |
|
109 | - |
|
110 | - /** |
|
111 | - * Get an external storage entry. |
|
112 | - * |
|
113 | - * @param int $id storage id |
|
114 | - * @param bool $testOnly whether to storage should only test the connection or do more things |
|
115 | - * @return DataResponse |
|
116 | - * |
|
117 | - * @NoAdminRequired |
|
118 | - */ |
|
119 | - public function show($id, $testOnly = true) { |
|
120 | - try { |
|
121 | - $storage = $this->service->getStorage($id); |
|
122 | - |
|
123 | - $this->updateStorageStatus($storage, $testOnly); |
|
124 | - } catch (NotFoundException $e) { |
|
125 | - return new DataResponse( |
|
126 | - [ |
|
127 | - 'message' => (string)$this->l10n->t('Storage with ID "%d" not found', array($id)) |
|
128 | - ], |
|
129 | - Http::STATUS_NOT_FOUND |
|
130 | - ); |
|
131 | - } |
|
132 | - |
|
133 | - $this->sanitizeStorage($storage); |
|
134 | - |
|
135 | - return new DataResponse( |
|
136 | - $this->formatStorageForUI($storage), |
|
137 | - Http::STATUS_OK |
|
138 | - ); |
|
139 | - } |
|
140 | - |
|
141 | - /** |
|
142 | - * Update an external storage entry. |
|
143 | - * Only allows setting user provided backend fields |
|
144 | - * |
|
145 | - * @param int $id storage id |
|
146 | - * @param array $backendOptions backend-specific options |
|
147 | - * @param bool $testOnly whether to storage should only test the connection or do more things |
|
148 | - * |
|
149 | - * @return DataResponse |
|
150 | - * |
|
151 | - * @NoAdminRequired |
|
152 | - */ |
|
153 | - public function update( |
|
154 | - $id, |
|
155 | - $backendOptions, |
|
156 | - $testOnly = true |
|
157 | - ) { |
|
158 | - try { |
|
159 | - $storage = $this->service->getStorage($id); |
|
160 | - $authMechanism = $storage->getAuthMechanism(); |
|
161 | - if ($authMechanism instanceof IUserProvided || $authMechanism instanceof UserGlobalAuth) { |
|
162 | - $authMechanism->saveBackendOptions($this->userSession->getUser(), $id, $backendOptions); |
|
163 | - $authMechanism->manipulateStorageConfig($storage, $this->userSession->getUser()); |
|
164 | - } else { |
|
165 | - return new DataResponse( |
|
166 | - [ |
|
167 | - 'message' => (string)$this->l10n->t('Storage with ID "%d" is not user editable', array($id)) |
|
168 | - ], |
|
169 | - Http::STATUS_FORBIDDEN |
|
170 | - ); |
|
171 | - } |
|
172 | - } catch (NotFoundException $e) { |
|
173 | - return new DataResponse( |
|
174 | - [ |
|
175 | - 'message' => (string)$this->l10n->t('Storage with ID "%d" not found', array($id)) |
|
176 | - ], |
|
177 | - Http::STATUS_NOT_FOUND |
|
178 | - ); |
|
179 | - } |
|
180 | - |
|
181 | - $this->updateStorageStatus($storage, $testOnly); |
|
182 | - $this->sanitizeStorage($storage); |
|
183 | - |
|
184 | - return new DataResponse( |
|
185 | - $this->formatStorageForUI($storage), |
|
186 | - Http::STATUS_OK |
|
187 | - ); |
|
188 | - |
|
189 | - } |
|
190 | - |
|
191 | - /** |
|
192 | - * Remove sensitive data from a StorageConfig before returning it to the user |
|
193 | - * |
|
194 | - * @param StorageConfig $storage |
|
195 | - */ |
|
196 | - protected function sanitizeStorage(StorageConfig $storage) { |
|
197 | - $storage->setBackendOptions([]); |
|
198 | - $storage->setMountOptions([]); |
|
199 | - |
|
200 | - if ($storage->getAuthMechanism() instanceof IUserProvided) { |
|
201 | - try { |
|
202 | - $storage->getAuthMechanism()->manipulateStorageConfig($storage, $this->userSession->getUser()); |
|
203 | - } catch (InsufficientDataForMeaningfulAnswerException $e) { |
|
204 | - // not configured yet |
|
205 | - } |
|
206 | - } |
|
207 | - } |
|
48 | + /** |
|
49 | + * @var IUserSession |
|
50 | + */ |
|
51 | + private $userSession; |
|
52 | + |
|
53 | + /** |
|
54 | + * Creates a new user global storages controller. |
|
55 | + * |
|
56 | + * @param string $AppName application name |
|
57 | + * @param IRequest $request request object |
|
58 | + * @param IL10N $l10n l10n service |
|
59 | + * @param UserGlobalStoragesService $userGlobalStoragesService storage service |
|
60 | + * @param IUserSession $userSession |
|
61 | + */ |
|
62 | + public function __construct( |
|
63 | + $AppName, |
|
64 | + IRequest $request, |
|
65 | + IL10N $l10n, |
|
66 | + UserGlobalStoragesService $userGlobalStoragesService, |
|
67 | + IUserSession $userSession, |
|
68 | + ILogger $logger |
|
69 | + ) { |
|
70 | + parent::__construct( |
|
71 | + $AppName, |
|
72 | + $request, |
|
73 | + $l10n, |
|
74 | + $userGlobalStoragesService, |
|
75 | + $logger |
|
76 | + ); |
|
77 | + $this->userSession = $userSession; |
|
78 | + } |
|
79 | + |
|
80 | + /** |
|
81 | + * Get all storage entries |
|
82 | + * |
|
83 | + * @return DataResponse |
|
84 | + * |
|
85 | + * @NoAdminRequired |
|
86 | + */ |
|
87 | + public function index() { |
|
88 | + $storages = $this->formatStoragesForUI($this->service->getUniqueStorages()); |
|
89 | + |
|
90 | + // remove configuration data, this must be kept private |
|
91 | + foreach ($storages as $storage) { |
|
92 | + $this->sanitizeStorage($storage); |
|
93 | + } |
|
94 | + |
|
95 | + return new DataResponse( |
|
96 | + $storages, |
|
97 | + Http::STATUS_OK |
|
98 | + ); |
|
99 | + } |
|
100 | + |
|
101 | + protected function manipulateStorageConfig(StorageConfig $storage) { |
|
102 | + /** @var AuthMechanism */ |
|
103 | + $authMechanism = $storage->getAuthMechanism(); |
|
104 | + $authMechanism->manipulateStorageConfig($storage, $this->userSession->getUser()); |
|
105 | + /** @var Backend */ |
|
106 | + $backend = $storage->getBackend(); |
|
107 | + $backend->manipulateStorageConfig($storage, $this->userSession->getUser()); |
|
108 | + } |
|
109 | + |
|
110 | + /** |
|
111 | + * Get an external storage entry. |
|
112 | + * |
|
113 | + * @param int $id storage id |
|
114 | + * @param bool $testOnly whether to storage should only test the connection or do more things |
|
115 | + * @return DataResponse |
|
116 | + * |
|
117 | + * @NoAdminRequired |
|
118 | + */ |
|
119 | + public function show($id, $testOnly = true) { |
|
120 | + try { |
|
121 | + $storage = $this->service->getStorage($id); |
|
122 | + |
|
123 | + $this->updateStorageStatus($storage, $testOnly); |
|
124 | + } catch (NotFoundException $e) { |
|
125 | + return new DataResponse( |
|
126 | + [ |
|
127 | + 'message' => (string)$this->l10n->t('Storage with ID "%d" not found', array($id)) |
|
128 | + ], |
|
129 | + Http::STATUS_NOT_FOUND |
|
130 | + ); |
|
131 | + } |
|
132 | + |
|
133 | + $this->sanitizeStorage($storage); |
|
134 | + |
|
135 | + return new DataResponse( |
|
136 | + $this->formatStorageForUI($storage), |
|
137 | + Http::STATUS_OK |
|
138 | + ); |
|
139 | + } |
|
140 | + |
|
141 | + /** |
|
142 | + * Update an external storage entry. |
|
143 | + * Only allows setting user provided backend fields |
|
144 | + * |
|
145 | + * @param int $id storage id |
|
146 | + * @param array $backendOptions backend-specific options |
|
147 | + * @param bool $testOnly whether to storage should only test the connection or do more things |
|
148 | + * |
|
149 | + * @return DataResponse |
|
150 | + * |
|
151 | + * @NoAdminRequired |
|
152 | + */ |
|
153 | + public function update( |
|
154 | + $id, |
|
155 | + $backendOptions, |
|
156 | + $testOnly = true |
|
157 | + ) { |
|
158 | + try { |
|
159 | + $storage = $this->service->getStorage($id); |
|
160 | + $authMechanism = $storage->getAuthMechanism(); |
|
161 | + if ($authMechanism instanceof IUserProvided || $authMechanism instanceof UserGlobalAuth) { |
|
162 | + $authMechanism->saveBackendOptions($this->userSession->getUser(), $id, $backendOptions); |
|
163 | + $authMechanism->manipulateStorageConfig($storage, $this->userSession->getUser()); |
|
164 | + } else { |
|
165 | + return new DataResponse( |
|
166 | + [ |
|
167 | + 'message' => (string)$this->l10n->t('Storage with ID "%d" is not user editable', array($id)) |
|
168 | + ], |
|
169 | + Http::STATUS_FORBIDDEN |
|
170 | + ); |
|
171 | + } |
|
172 | + } catch (NotFoundException $e) { |
|
173 | + return new DataResponse( |
|
174 | + [ |
|
175 | + 'message' => (string)$this->l10n->t('Storage with ID "%d" not found', array($id)) |
|
176 | + ], |
|
177 | + Http::STATUS_NOT_FOUND |
|
178 | + ); |
|
179 | + } |
|
180 | + |
|
181 | + $this->updateStorageStatus($storage, $testOnly); |
|
182 | + $this->sanitizeStorage($storage); |
|
183 | + |
|
184 | + return new DataResponse( |
|
185 | + $this->formatStorageForUI($storage), |
|
186 | + Http::STATUS_OK |
|
187 | + ); |
|
188 | + |
|
189 | + } |
|
190 | + |
|
191 | + /** |
|
192 | + * Remove sensitive data from a StorageConfig before returning it to the user |
|
193 | + * |
|
194 | + * @param StorageConfig $storage |
|
195 | + */ |
|
196 | + protected function sanitizeStorage(StorageConfig $storage) { |
|
197 | + $storage->setBackendOptions([]); |
|
198 | + $storage->setMountOptions([]); |
|
199 | + |
|
200 | + if ($storage->getAuthMechanism() instanceof IUserProvided) { |
|
201 | + try { |
|
202 | + $storage->getAuthMechanism()->manipulateStorageConfig($storage, $this->userSession->getUser()); |
|
203 | + } catch (InsufficientDataForMeaningfulAnswerException $e) { |
|
204 | + // not configured yet |
|
205 | + } |
|
206 | + } |
|
207 | + } |
|
208 | 208 | |
209 | 209 | } |
@@ -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 | ); |
@@ -40,151 +40,151 @@ |
||
40 | 40 | * Global storages controller |
41 | 41 | */ |
42 | 42 | class GlobalStoragesController extends StoragesController { |
43 | - /** |
|
44 | - * Creates a new global storages controller. |
|
45 | - * |
|
46 | - * @param string $AppName application name |
|
47 | - * @param IRequest $request request object |
|
48 | - * @param IL10N $l10n l10n service |
|
49 | - * @param GlobalStoragesService $globalStoragesService storage service |
|
50 | - * @param ILogger $logger |
|
51 | - */ |
|
52 | - public function __construct( |
|
53 | - $AppName, |
|
54 | - IRequest $request, |
|
55 | - IL10N $l10n, |
|
56 | - GlobalStoragesService $globalStoragesService, |
|
57 | - ILogger $logger |
|
58 | - ) { |
|
59 | - parent::__construct( |
|
60 | - $AppName, |
|
61 | - $request, |
|
62 | - $l10n, |
|
63 | - $globalStoragesService, |
|
64 | - $logger |
|
65 | - ); |
|
66 | - } |
|
67 | - |
|
68 | - /** |
|
69 | - * Create an external storage entry. |
|
70 | - * |
|
71 | - * @param string $mountPoint storage mount point |
|
72 | - * @param string $backend backend identifier |
|
73 | - * @param string $authMechanism authentication mechanism identifier |
|
74 | - * @param array $backendOptions backend-specific options |
|
75 | - * @param array $mountOptions mount-specific options |
|
76 | - * @param array $applicableUsers users for which to mount the storage |
|
77 | - * @param array $applicableGroups groups for which to mount the storage |
|
78 | - * @param int $priority priority |
|
79 | - * |
|
80 | - * @return DataResponse |
|
81 | - */ |
|
82 | - public function create( |
|
83 | - $mountPoint, |
|
84 | - $backend, |
|
85 | - $authMechanism, |
|
86 | - $backendOptions, |
|
87 | - $mountOptions, |
|
88 | - $applicableUsers, |
|
89 | - $applicableGroups, |
|
90 | - $priority |
|
91 | - ) { |
|
92 | - $newStorage = $this->createStorage( |
|
93 | - $mountPoint, |
|
94 | - $backend, |
|
95 | - $authMechanism, |
|
96 | - $backendOptions, |
|
97 | - $mountOptions, |
|
98 | - $applicableUsers, |
|
99 | - $applicableGroups, |
|
100 | - $priority |
|
101 | - ); |
|
102 | - if ($newStorage instanceof DataResponse) { |
|
103 | - return $newStorage; |
|
104 | - } |
|
105 | - |
|
106 | - $response = $this->validate($newStorage); |
|
107 | - if (!empty($response)) { |
|
108 | - return $response; |
|
109 | - } |
|
110 | - |
|
111 | - $newStorage = $this->service->addStorage($newStorage); |
|
112 | - |
|
113 | - $this->updateStorageStatus($newStorage); |
|
114 | - |
|
115 | - return new DataResponse( |
|
116 | - $this->formatStorageForUI($newStorage), |
|
117 | - Http::STATUS_CREATED |
|
118 | - ); |
|
119 | - } |
|
120 | - |
|
121 | - /** |
|
122 | - * Update an external storage entry. |
|
123 | - * |
|
124 | - * @param int $id storage id |
|
125 | - * @param string $mountPoint storage mount point |
|
126 | - * @param string $backend backend identifier |
|
127 | - * @param string $authMechanism authentication mechansim identifier |
|
128 | - * @param array $backendOptions backend-specific options |
|
129 | - * @param array $mountOptions mount-specific options |
|
130 | - * @param array $applicableUsers users for which to mount the storage |
|
131 | - * @param array $applicableGroups groups for which to mount the storage |
|
132 | - * @param int $priority priority |
|
133 | - * @param bool $testOnly whether to storage should only test the connection or do more things |
|
134 | - * |
|
135 | - * @return DataResponse |
|
136 | - */ |
|
137 | - public function update( |
|
138 | - $id, |
|
139 | - $mountPoint, |
|
140 | - $backend, |
|
141 | - $authMechanism, |
|
142 | - $backendOptions, |
|
143 | - $mountOptions, |
|
144 | - $applicableUsers, |
|
145 | - $applicableGroups, |
|
146 | - $priority, |
|
147 | - $testOnly = true |
|
148 | - ) { |
|
149 | - $storage = $this->createStorage( |
|
150 | - $mountPoint, |
|
151 | - $backend, |
|
152 | - $authMechanism, |
|
153 | - $backendOptions, |
|
154 | - $mountOptions, |
|
155 | - $applicableUsers, |
|
156 | - $applicableGroups, |
|
157 | - $priority |
|
158 | - ); |
|
159 | - if ($storage instanceof DataResponse) { |
|
160 | - return $storage; |
|
161 | - } |
|
162 | - $storage->setId($id); |
|
163 | - |
|
164 | - $response = $this->validate($storage); |
|
165 | - if (!empty($response)) { |
|
166 | - return $response; |
|
167 | - } |
|
168 | - |
|
169 | - try { |
|
170 | - $storage = $this->service->updateStorage($storage); |
|
171 | - } catch (NotFoundException $e) { |
|
172 | - return new DataResponse( |
|
173 | - [ |
|
174 | - 'message' => (string)$this->l10n->t('Storage with ID "%d" not found', array($id)) |
|
175 | - ], |
|
176 | - Http::STATUS_NOT_FOUND |
|
177 | - ); |
|
178 | - } |
|
179 | - |
|
180 | - $this->updateStorageStatus($storage, $testOnly); |
|
181 | - |
|
182 | - return new DataResponse( |
|
183 | - $this->formatStorageForUI($storage), |
|
184 | - Http::STATUS_OK |
|
185 | - ); |
|
186 | - |
|
187 | - } |
|
43 | + /** |
|
44 | + * Creates a new global storages controller. |
|
45 | + * |
|
46 | + * @param string $AppName application name |
|
47 | + * @param IRequest $request request object |
|
48 | + * @param IL10N $l10n l10n service |
|
49 | + * @param GlobalStoragesService $globalStoragesService storage service |
|
50 | + * @param ILogger $logger |
|
51 | + */ |
|
52 | + public function __construct( |
|
53 | + $AppName, |
|
54 | + IRequest $request, |
|
55 | + IL10N $l10n, |
|
56 | + GlobalStoragesService $globalStoragesService, |
|
57 | + ILogger $logger |
|
58 | + ) { |
|
59 | + parent::__construct( |
|
60 | + $AppName, |
|
61 | + $request, |
|
62 | + $l10n, |
|
63 | + $globalStoragesService, |
|
64 | + $logger |
|
65 | + ); |
|
66 | + } |
|
67 | + |
|
68 | + /** |
|
69 | + * Create an external storage entry. |
|
70 | + * |
|
71 | + * @param string $mountPoint storage mount point |
|
72 | + * @param string $backend backend identifier |
|
73 | + * @param string $authMechanism authentication mechanism identifier |
|
74 | + * @param array $backendOptions backend-specific options |
|
75 | + * @param array $mountOptions mount-specific options |
|
76 | + * @param array $applicableUsers users for which to mount the storage |
|
77 | + * @param array $applicableGroups groups for which to mount the storage |
|
78 | + * @param int $priority priority |
|
79 | + * |
|
80 | + * @return DataResponse |
|
81 | + */ |
|
82 | + public function create( |
|
83 | + $mountPoint, |
|
84 | + $backend, |
|
85 | + $authMechanism, |
|
86 | + $backendOptions, |
|
87 | + $mountOptions, |
|
88 | + $applicableUsers, |
|
89 | + $applicableGroups, |
|
90 | + $priority |
|
91 | + ) { |
|
92 | + $newStorage = $this->createStorage( |
|
93 | + $mountPoint, |
|
94 | + $backend, |
|
95 | + $authMechanism, |
|
96 | + $backendOptions, |
|
97 | + $mountOptions, |
|
98 | + $applicableUsers, |
|
99 | + $applicableGroups, |
|
100 | + $priority |
|
101 | + ); |
|
102 | + if ($newStorage instanceof DataResponse) { |
|
103 | + return $newStorage; |
|
104 | + } |
|
105 | + |
|
106 | + $response = $this->validate($newStorage); |
|
107 | + if (!empty($response)) { |
|
108 | + return $response; |
|
109 | + } |
|
110 | + |
|
111 | + $newStorage = $this->service->addStorage($newStorage); |
|
112 | + |
|
113 | + $this->updateStorageStatus($newStorage); |
|
114 | + |
|
115 | + return new DataResponse( |
|
116 | + $this->formatStorageForUI($newStorage), |
|
117 | + Http::STATUS_CREATED |
|
118 | + ); |
|
119 | + } |
|
120 | + |
|
121 | + /** |
|
122 | + * Update an external storage entry. |
|
123 | + * |
|
124 | + * @param int $id storage id |
|
125 | + * @param string $mountPoint storage mount point |
|
126 | + * @param string $backend backend identifier |
|
127 | + * @param string $authMechanism authentication mechansim identifier |
|
128 | + * @param array $backendOptions backend-specific options |
|
129 | + * @param array $mountOptions mount-specific options |
|
130 | + * @param array $applicableUsers users for which to mount the storage |
|
131 | + * @param array $applicableGroups groups for which to mount the storage |
|
132 | + * @param int $priority priority |
|
133 | + * @param bool $testOnly whether to storage should only test the connection or do more things |
|
134 | + * |
|
135 | + * @return DataResponse |
|
136 | + */ |
|
137 | + public function update( |
|
138 | + $id, |
|
139 | + $mountPoint, |
|
140 | + $backend, |
|
141 | + $authMechanism, |
|
142 | + $backendOptions, |
|
143 | + $mountOptions, |
|
144 | + $applicableUsers, |
|
145 | + $applicableGroups, |
|
146 | + $priority, |
|
147 | + $testOnly = true |
|
148 | + ) { |
|
149 | + $storage = $this->createStorage( |
|
150 | + $mountPoint, |
|
151 | + $backend, |
|
152 | + $authMechanism, |
|
153 | + $backendOptions, |
|
154 | + $mountOptions, |
|
155 | + $applicableUsers, |
|
156 | + $applicableGroups, |
|
157 | + $priority |
|
158 | + ); |
|
159 | + if ($storage instanceof DataResponse) { |
|
160 | + return $storage; |
|
161 | + } |
|
162 | + $storage->setId($id); |
|
163 | + |
|
164 | + $response = $this->validate($storage); |
|
165 | + if (!empty($response)) { |
|
166 | + return $response; |
|
167 | + } |
|
168 | + |
|
169 | + try { |
|
170 | + $storage = $this->service->updateStorage($storage); |
|
171 | + } catch (NotFoundException $e) { |
|
172 | + return new DataResponse( |
|
173 | + [ |
|
174 | + 'message' => (string)$this->l10n->t('Storage with ID "%d" not found', array($id)) |
|
175 | + ], |
|
176 | + Http::STATUS_NOT_FOUND |
|
177 | + ); |
|
178 | + } |
|
179 | + |
|
180 | + $this->updateStorageStatus($storage, $testOnly); |
|
181 | + |
|
182 | + return new DataResponse( |
|
183 | + $this->formatStorageForUI($storage), |
|
184 | + Http::STATUS_OK |
|
185 | + ); |
|
186 | + |
|
187 | + } |
|
188 | 188 | |
189 | 189 | |
190 | 190 | } |
@@ -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 username (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 username (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 | } |
@@ -11,9 +11,9 @@ |
||
11 | 11 | <p class="settings-hint"><?php p($l->t('Allows users to share a personalized link to a file or folder by putting in an email address.')); ?></p> |
12 | 12 | |
13 | 13 | <p> |
14 | - <input id="sendPasswordMail" type="checkbox" class="checkbox" <?php if($_['sendPasswordMail']) p('checked'); ?> /> |
|
14 | + <input id="sendPasswordMail" type="checkbox" class="checkbox" <?php if ($_['sendPasswordMail']) p('checked'); ?> /> |
|
15 | 15 | <label for="sendPasswordMail"><?php p($l->t('Send password by mail')); ?></label><br/> |
16 | - <input id="enforcePasswordProtection" type="checkbox" class="checkbox" <?php if($_['enforcePasswordProtection']) p('checked'); ?> /> |
|
16 | + <input id="enforcePasswordProtection" type="checkbox" class="checkbox" <?php if ($_['enforcePasswordProtection']) p('checked'); ?> /> |
|
17 | 17 | <label for="enforcePasswordProtection"><?php p($l->t('Enforce password protection')); ?></label> |
18 | 18 | </p> |
19 | 19 |
@@ -11,9 +11,15 @@ |
||
11 | 11 | <p class="settings-hint"><?php p($l->t('Allows users to share a personalized link to a file or folder by putting in an email address.')); ?></p> |
12 | 12 | |
13 | 13 | <p> |
14 | - <input id="sendPasswordMail" type="checkbox" class="checkbox" <?php if($_['sendPasswordMail']) p('checked'); ?> /> |
|
14 | + <input id="sendPasswordMail" type="checkbox" class="checkbox" <?php if($_['sendPasswordMail']) { |
|
15 | + p('checked'); |
|
16 | +} |
|
17 | +?> /> |
|
15 | 18 | <label for="sendPasswordMail"><?php p($l->t('Send password by mail')); ?></label><br/> |
16 | - <input id="enforcePasswordProtection" type="checkbox" class="checkbox" <?php if($_['enforcePasswordProtection']) p('checked'); ?> /> |
|
19 | + <input id="enforcePasswordProtection" type="checkbox" class="checkbox" <?php if($_['enforcePasswordProtection']) { |
|
20 | + p('checked'); |
|
21 | +} |
|
22 | +?> /> |
|
17 | 23 | <label for="enforcePasswordProtection"><?php p($l->t('Enforce password protection')); ?></label> |
18 | 24 | </p> |
19 | 25 |