diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php | 2 | ||||
-rw-r--r-- | apps/files_sharing/appinfo/routes.php | 2 | ||||
-rw-r--r-- | apps/files_sharing/lib/Controller/ShareController.php | 2 | ||||
-rw-r--r-- | apps/testing/appinfo/routes.php | 20 | ||||
-rw-r--r-- | apps/testing/lib/Controller/RateLimitTestController.php | 52 | ||||
-rw-r--r-- | apps/user_ldap/lib/Access.php | 22 | ||||
-rw-r--r-- | apps/user_ldap/lib/Group_LDAP.php | 6 | ||||
-rw-r--r-- | apps/user_ldap/lib/User_LDAP.php | 2 | ||||
-rw-r--r-- | apps/user_ldap/tests/Group_LDAPTest.php | 8 | ||||
-rw-r--r-- | apps/user_ldap/tests/User_LDAPTest.php | 2 |
10 files changed, 94 insertions, 24 deletions
diff --git a/apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php b/apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php index d7e466d1a64..9f848fbbb78 100644 --- a/apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php +++ b/apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php @@ -120,7 +120,7 @@ class MountPublicLinkController extends Controller { * * @NoCSRFRequired * @PublicPage - * @BruteForceProtection publicLink2FederatedShare + * @BruteForceProtection(action=publicLink2FederatedShare) * * @param string $shareWith * @param string $token diff --git a/apps/files_sharing/appinfo/routes.php b/apps/files_sharing/appinfo/routes.php index 439d46253d4..56eece341a9 100644 --- a/apps/files_sharing/appinfo/routes.php +++ b/apps/files_sharing/appinfo/routes.php @@ -125,8 +125,6 @@ $application->registerRoutes($this, [ ]); /** @var $this \OCP\Route\IRouter */ -$this->create('files_sharing_ajax_list', 'ajax/list.php') - ->actionInclude('files_sharing/ajax/list.php'); $this->create('sharing_external_shareinfo', '/shareinfo') ->actionInclude('files_sharing/ajax/shareinfo.php'); diff --git a/apps/files_sharing/lib/Controller/ShareController.php b/apps/files_sharing/lib/Controller/ShareController.php index 2c6e953a0f5..732a1d32ee7 100644 --- a/apps/files_sharing/lib/Controller/ShareController.php +++ b/apps/files_sharing/lib/Controller/ShareController.php @@ -160,7 +160,7 @@ class ShareController extends Controller { /** * @PublicPage * @UseSession - * @BruteForceProtection publicLinkAuth + * @BruteForceProtection(action=publicLinkAuth) * * Authenticates against password-protected shares * @param string $token diff --git a/apps/testing/appinfo/routes.php b/apps/testing/appinfo/routes.php index 13caa2289df..d45cfe00eca 100644 --- a/apps/testing/appinfo/routes.php +++ b/apps/testing/appinfo/routes.php @@ -25,12 +25,32 @@ namespace OCA\Testing\AppInfo; use OCA\Testing\Config; use OCA\Testing\Locking\Provisioning; use OCP\API; +use OCP\AppFramework\App; $config = new Config( \OC::$server->getConfig(), \OC::$server->getRequest() ); +$app = new App('testing'); +$app->registerRoutes( + $this, + [ + 'routes' => [ + [ + 'name' => 'RateLimitTest#userAndAnonProtected', + 'url' => '/userAndAnonProtected', + 'verb' => 'GET', + ], + [ + 'name' => 'RateLimitTest#onlyAnonProtected', + 'url' => '/anonProtected', + 'verb' => 'GET', + ], + ] + ] +); + API::register( 'post', '/apps/testing/api/v1/app/{appid}/{configkey}', diff --git a/apps/testing/lib/Controller/RateLimitTestController.php b/apps/testing/lib/Controller/RateLimitTestController.php new file mode 100644 index 00000000000..c43d33e5335 --- /dev/null +++ b/apps/testing/lib/Controller/RateLimitTestController.php @@ -0,0 +1,52 @@ +<?php +/** + * @copyright Copyright (c) 2017 Lukas Reschke <lukas@statuscode.ch> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OCA\Testing\Controller; + +use OCP\AppFramework\Controller; +use OCP\AppFramework\Http\JSONResponse; + +class RateLimitTestController extends Controller { + /** + * @PublicPage + * @NoCSRFRequired + * + * @UserRateThrottle(limit=5, period=100) + * @AnonRateThrottle(limit=1, period=100) + * + * @return JSONResponse + */ + public function userAndAnonProtected() { + return new JSONResponse(); + } + + /** + * @PublicPage + * @NoCSRFRequired + * + * @AnonRateThrottle(limit=1, period=10) + * + * @return JSONResponse + */ + public function onlyAnonProtected() { + return new JSONResponse(); + } +} diff --git a/apps/user_ldap/lib/Access.php b/apps/user_ldap/lib/Access.php index dbc4f5b0448..959a8dd2b8e 100644 --- a/apps/user_ldap/lib/Access.php +++ b/apps/user_ldap/lib/Access.php @@ -595,8 +595,8 @@ class Access extends LDAPUtility implements IUserTools { * * gives back the user names as they are used ownClod internally */ - public function ownCloudUserNames($ldapUsers) { - return $this->ldap2ownCloudNames($ldapUsers, true); + public function nextcloudUserNames($ldapUsers) { + return $this->ldap2NextcloudNames($ldapUsers, true); } /** @@ -606,8 +606,8 @@ class Access extends LDAPUtility implements IUserTools { * * gives back the group names as they are used ownClod internally */ - public function ownCloudGroupNames($ldapGroups) { - return $this->ldap2ownCloudNames($ldapGroups, false); + public function nextcloudGroupNames($ldapGroups) { + return $this->ldap2NextcloudNames($ldapGroups, false); } /** @@ -615,14 +615,14 @@ class Access extends LDAPUtility implements IUserTools { * @param bool $isUsers * @return array */ - private function ldap2ownCloudNames($ldapObjects, $isUsers) { + private function ldap2NextcloudNames($ldapObjects, $isUsers) { if($isUsers) { $nameAttribute = $this->connection->ldapUserDisplayName; $sndAttribute = $this->connection->ldapUserDisplayName2; } else { $nameAttribute = $this->connection->ldapGroupDisplayName; } - $ownCloudNames = array(); + $nextcloudNames = array(); foreach($ldapObjects as $ldapObject) { $nameByLDAP = null; @@ -634,9 +634,9 @@ class Access extends LDAPUtility implements IUserTools { $nameByLDAP = $ldapObject[$nameAttribute][0]; } - $ocName = $this->dn2ocname($ldapObject['dn'][0], $nameByLDAP, $isUsers); - if($ocName) { - $ownCloudNames[] = $ocName; + $ncName = $this->dn2ocname($ldapObject['dn'][0], $nameByLDAP, $isUsers); + if($ncName) { + $nextcloudNames[] = $ncName; if($isUsers) { //cache the user names so it does not need to be retrieved //again later (e.g. sharing dialogue). @@ -645,11 +645,11 @@ class Access extends LDAPUtility implements IUserTools { } $sndName = isset($ldapObject[$sndAttribute][0]) ? $ldapObject[$sndAttribute][0] : ''; - $this->cacheUserDisplayName($ocName, $nameByLDAP, $sndName); + $this->cacheUserDisplayName($ncName, $nameByLDAP, $sndName); } } } - return $NextcloudNames; + return $nextcloudNames; } /** diff --git a/apps/user_ldap/lib/Group_LDAP.php b/apps/user_ldap/lib/Group_LDAP.php index f1ea831e485..b6013e77766 100644 --- a/apps/user_ldap/lib/Group_LDAP.php +++ b/apps/user_ldap/lib/Group_LDAP.php @@ -388,7 +388,7 @@ class Group_LDAP extends BackendUtility implements \OCP\GroupInterface { $limit, $offset ); - return $this->access->ownCloudUserNames($users); + return $this->access->nextcloudUserNames($users); } catch (\Exception $e) { return array(); } @@ -541,7 +541,7 @@ class Group_LDAP extends BackendUtility implements \OCP\GroupInterface { $groups = array_merge($groups, $this->cachedGroupsByMember[$uid]); } else { $groupsByMember = array_values($this->getGroupsByMember($uid)); - $groupsByMember = $this->access->ownCloudGroupNames($groupsByMember); + $groupsByMember = $this->access->nextcloudGroupNames($groupsByMember); $this->cachedGroupsByMember[$uid] = $groupsByMember; $groups = array_merge($groups, $groupsByMember); } @@ -804,7 +804,7 @@ class Group_LDAP extends BackendUtility implements \OCP\GroupInterface { array($this->access->connection->ldapGroupDisplayName, 'dn'), $limit, $offset); - $ldap_groups = $this->access->ownCloudGroupNames($ldap_groups); + $ldap_groups = $this->access->nextcloudGroupNames($ldap_groups); $this->access->connection->writeToCache($cacheKey, $ldap_groups); return $ldap_groups; diff --git a/apps/user_ldap/lib/User_LDAP.php b/apps/user_ldap/lib/User_LDAP.php index 44de3f5da40..fa959fd9a81 100644 --- a/apps/user_ldap/lib/User_LDAP.php +++ b/apps/user_ldap/lib/User_LDAP.php @@ -234,7 +234,7 @@ class User_LDAP extends BackendUtility implements \OCP\IUserBackend, \OCP\UserIn $filter, $this->access->userManager->getAttributes(true), $limit, $offset); - $ldap_users = $this->access->ownCloudUserNames($ldap_users); + $ldap_users = $this->access->nextcloudUserNames($ldap_users); Util::writeLog('user_ldap', 'getUsers: '.count($ldap_users). ' Users found', Util::DEBUG); $this->access->connection->writeToCache($cachekey, $ldap_users); diff --git a/apps/user_ldap/tests/Group_LDAPTest.php b/apps/user_ldap/tests/Group_LDAPTest.php index 906db6bb17b..621a427eaac 100644 --- a/apps/user_ldap/tests/Group_LDAPTest.php +++ b/apps/user_ldap/tests/Group_LDAPTest.php @@ -315,7 +315,7 @@ class Group_LDAPTest extends \Test\TestCase { $this->enableGroups($access); $access->expects($this->once()) - ->method('ownCloudGroupNames') + ->method('nextcloudGroupNames') ->will($this->returnValue(array('group1', 'group2'))); $groupBackend = new GroupLDAP($access); @@ -350,7 +350,7 @@ class Group_LDAPTest extends \Test\TestCase { ->will($this->returnValue('cn=foobar,dc=foo,dc=bar')); $access->expects($this->once()) - ->method('ownCloudUserNames') + ->method('nextcloudUserNames') ->will($this->returnValue(array('lisa', 'bart', 'kira', 'brad'))); $groupBackend = new GroupLDAP($access); @@ -451,7 +451,7 @@ class Group_LDAPTest extends \Test\TestCase { ->with($dn, 'memberOf'); $access->expects($this->once()) - ->method('ownCloudGroupNames') + ->method('nextcloudGroupNames') ->will($this->returnValue([])); $groupBackend = new GroupLDAP($access); @@ -496,7 +496,7 @@ class Group_LDAPTest extends \Test\TestCase { ]; $access->expects($this->once()) - ->method('ownCloudGroupNames') + ->method('nextcloudGroupNames') ->with([$group1, $group2]) ->will($this->returnValue(['group1', 'group2'])); diff --git a/apps/user_ldap/tests/User_LDAPTest.php b/apps/user_ldap/tests/User_LDAPTest.php index f1a23f9a6c8..1b1f9fdec78 100644 --- a/apps/user_ldap/tests/User_LDAPTest.php +++ b/apps/user_ldap/tests/User_LDAPTest.php @@ -349,7 +349,7 @@ class User_LDAPTest extends TestCase { })); $access->expects($this->any()) - ->method('ownCloudUserNames') + ->method('nextcloudUserNames') ->will($this->returnArgument(0)); } |