Skip to content

Commit 47bbd8b

Browse files
authored
Merge branch 'master' into bugfix-autodelete-role
2 parents a7fff0a + 42b6d98 commit 47bbd8b

4 files changed

Lines changed: 13 additions & 9 deletions

File tree

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Apollo 2.5.0
1313
* [Feature: Enhanced parameter verification for edit item](https://github.com/apolloconfig/apollo/pull/5376)
1414
* [Feature: Added a new feature to get instance count by namespace.](https://github.com/apolloconfig/apollo/pull/5381)
1515
* [Bugfix: Remove cluster-related roles and permissions upon deletion](https://github.com/apolloconfig/apollo/pull/5395)
16+
* [Security: Prevent unauthorized access to other users' apps in /apps/by-owner endpoint](https://github.com/apolloconfig/apollo/pull/5396)
1617

1718
------------------
1819
All issues and pull requests are [here](https://github.com/apolloconfig/apollo/milestone/16?closed=1)

apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/AppController.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import com.ctrip.framework.apollo.core.ConfigConsts;
2929
import com.ctrip.framework.apollo.portal.component.PortalSettings;
3030
import com.ctrip.framework.apollo.portal.enricher.adapter.AppDtoUserInfoEnrichedAdapter;
31+
import com.ctrip.framework.apollo.portal.entity.bo.UserInfo;
3132
import com.ctrip.framework.apollo.portal.entity.model.AppModel;
3233
import com.ctrip.framework.apollo.portal.entity.po.Role;
3334
import com.ctrip.framework.apollo.portal.entity.vo.EnvClusterInfo;
@@ -102,11 +103,14 @@ public List<App> findApps(@RequestParam(value = "appIds", required = false) Stri
102103
return appService.findByAppIds(Sets.newHashSet(appIds.split(",")));
103104
}
104105

105-
@GetMapping("/by-owner")
106-
public List<App> findAppsByOwner(@RequestParam("owner") String owner, Pageable page) {
106+
@GetMapping("/by-self")
107+
public List<App> findAppsBySelf(Pageable page) {
108+
UserInfo loginUser = userInfoHolder.getUser();
109+
String userId = loginUser.getUserId();
110+
107111
Set<String> appIds = Sets.newHashSet();
108112

109-
List<Role> userRoles = rolePermissionService.findUserRoles(owner);
113+
List<Role> userRoles = rolePermissionService.findUserRoles(userId);
110114

111115
for (Role role : userRoles) {
112116
String appId = RoleUtils.extractAppIdFromRoleName(role.getRoleName());

apollo-portal/src/main/resources/static/scripts/controller/IndexController.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ function IndexController($scope, $window, $translate, toastr, AppUtil, AppServic
7676

7777
function getUserCreatedApps() {
7878
var size = 10;
79-
AppService.find_app_by_owner($scope.userId, $scope.createdAppPage, size)
79+
AppService.find_app_by_self($scope.createdAppPage, size)
8080
.then(function (result) {
8181
$scope.createdAppPage += 1;
8282
$scope.hasMoreCreatedApps = result.length == size;

apollo-portal/src/main/resources/static/scripts/services/AppService.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ appService.service('AppService', ['$resource', '$q', 'AppUtil', function ($resou
2121
isArray: true,
2222
url: AppUtil.prefixPath() + '/apps'
2323
},
24-
find_app_by_owner: {
24+
find_app_by_self: {
2525
method: 'GET',
2626
isArray: true,
27-
url: AppUtil.prefixPath() + '/apps/by-owner'
27+
url: AppUtil.prefixPath() + '/apps/by-self'
2828
},
2929
load_navtree: {
3030
method: 'GET',
@@ -89,10 +89,9 @@ appService.service('AppService', ['$resource', '$q', 'AppUtil', function ($resou
8989
});
9090
return d.promise;
9191
},
92-
find_app_by_owner: function (owner, page, size) {
92+
find_app_by_self: function (page, size) {
9393
var d = $q.defer();
94-
app_resource.find_app_by_owner({
95-
owner: owner,
94+
app_resource.find_app_by_self({
9695
page: page,
9796
size: size
9897
}, function (result) {

0 commit comments

Comments
 (0)