From eb21142dad1ba7e6dc1ebb9f20b0e146f2daaca5 Mon Sep 17 00:00:00 2001 From: zhangle Date: Wed, 12 Oct 2016 11:48:39 +0800 Subject: [PATCH] assign application namespace role when create app --- .../portal/service/RoleInitializationService.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/RoleInitializationService.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/RoleInitializationService.java index b79526791..07af19ced 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/RoleInitializationService.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/RoleInitializationService.java @@ -8,6 +8,7 @@ import com.ctrip.framework.apollo.common.entity.App; import com.ctrip.framework.apollo.core.ConfigConsts; import com.ctrip.framework.apollo.portal.auth.UserInfoHolder; import com.ctrip.framework.apollo.portal.constant.PermissionType; +import com.ctrip.framework.apollo.portal.constant.RoleType; import com.ctrip.framework.apollo.portal.entity.po.Permission; import com.ctrip.framework.apollo.portal.entity.po.Role; import com.ctrip.framework.apollo.portal.util.RoleUtils; @@ -36,17 +37,23 @@ public class RoleInitializationService { if (rolePermissionService.findRoleByRoleName(appMasterRoleName) != null) { return; } - String operaterUserId = userInfoHolder.getUser().getUserId(); + String operator = userInfoHolder.getUser().getUserId(); //create app permissions createAppMasterRole(appId); //assign master role to user rolePermissionService .assignRoleToUsers(RoleUtils.buildAppMasterRoleName(appId), Sets.newHashSet(app.getOwnerName()), - operaterUserId); + operator); initNamespaceRoles(appId, ConfigConsts.NAMESPACE_APPLICATION); + //assign modify、release namespace role to user + rolePermissionService.assignRoleToUsers(RoleUtils.buildNamespaceRoleName(appId, ConfigConsts.NAMESPACE_APPLICATION, RoleType.MODIFY_NAMESPACE), + Sets.newHashSet(operator), operator); + rolePermissionService.assignRoleToUsers(RoleUtils.buildNamespaceRoleName(appId, ConfigConsts.NAMESPACE_APPLICATION, RoleType.RELEASE_NAMESPACE), + Sets.newHashSet(operator), operator); + } @Transactional -- GitLab