Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
apollo
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
openSource
apollo
Commits
40ef0bd1
Commit
40ef0bd1
authored
Oct 12, 2016
by
Jason Song
Committed by
GitHub
Oct 12, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #427 from lepdou/assign_role_when_create_namespace
default assign modify、release namespace role to namespace creator
parents
f5dd22eb
eb21142d
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
7 deletions
+26
-7
NamespaceController.java
...amework/apollo/portal/controller/NamespaceController.java
+17
-1
RoleInitializationService.java
...work/apollo/portal/service/RoleInitializationService.java
+9
-2
common-style.css
...-portal/src/main/resources/static/styles/common-style.css
+0
-4
No files found.
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/NamespaceController.java
View file @
40ef0bd1
package
com
.
ctrip
.
framework
.
apollo
.
portal
.
controller
;
package
com
.
ctrip
.
framework
.
apollo
.
portal
.
controller
;
import
com.google.common.collect.Sets
;
import
com.ctrip.framework.apollo.common.dto.NamespaceDTO
;
import
com.ctrip.framework.apollo.common.dto.NamespaceDTO
;
import
com.ctrip.framework.apollo.common.entity.App
;
import
com.ctrip.framework.apollo.common.entity.App
;
import
com.ctrip.framework.apollo.common.entity.AppNamespace
;
import
com.ctrip.framework.apollo.common.entity.AppNamespace
;
...
@@ -10,6 +12,7 @@ import com.ctrip.framework.apollo.core.enums.ConfigFileFormat;
...
@@ -10,6 +12,7 @@ import com.ctrip.framework.apollo.core.enums.ConfigFileFormat;
import
com.ctrip.framework.apollo.core.enums.Env
;
import
com.ctrip.framework.apollo.core.enums.Env
;
import
com.ctrip.framework.apollo.core.utils.StringUtils
;
import
com.ctrip.framework.apollo.core.utils.StringUtils
;
import
com.ctrip.framework.apollo.portal.auth.UserInfoHolder
;
import
com.ctrip.framework.apollo.portal.auth.UserInfoHolder
;
import
com.ctrip.framework.apollo.portal.constant.RoleType
;
import
com.ctrip.framework.apollo.portal.entity.form.NamespaceCreationModel
;
import
com.ctrip.framework.apollo.portal.entity.form.NamespaceCreationModel
;
import
com.ctrip.framework.apollo.portal.entity.vo.NamespaceVO
;
import
com.ctrip.framework.apollo.portal.entity.vo.NamespaceVO
;
import
com.ctrip.framework.apollo.portal.listener.AppNamespaceCreationEvent
;
import
com.ctrip.framework.apollo.portal.listener.AppNamespaceCreationEvent
;
...
@@ -17,6 +20,8 @@ import com.ctrip.framework.apollo.portal.service.AppNamespaceService;
...
@@ -17,6 +20,8 @@ import com.ctrip.framework.apollo.portal.service.AppNamespaceService;
import
com.ctrip.framework.apollo.portal.service.AppService
;
import
com.ctrip.framework.apollo.portal.service.AppService
;
import
com.ctrip.framework.apollo.portal.service.NamespaceService
;
import
com.ctrip.framework.apollo.portal.service.NamespaceService
;
import
com.ctrip.framework.apollo.portal.service.RoleInitializationService
;
import
com.ctrip.framework.apollo.portal.service.RoleInitializationService
;
import
com.ctrip.framework.apollo.portal.service.RolePermissionService
;
import
com.ctrip.framework.apollo.portal.util.RoleUtils
;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.Cat
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
...
@@ -53,6 +58,8 @@ public class NamespaceController {
...
@@ -53,6 +58,8 @@ public class NamespaceController {
private
AppNamespaceService
appNamespaceService
;
private
AppNamespaceService
appNamespaceService
;
@Autowired
@Autowired
private
RoleInitializationService
roleInitializationService
;
private
RoleInitializationService
roleInitializationService
;
@Autowired
private
RolePermissionService
rolePermissionService
;
@RequestMapping
(
"/appnamespaces/public"
)
@RequestMapping
(
"/appnamespaces/public"
)
public
List
<
AppNamespace
>
findPublicAppNamespaces
()
{
public
List
<
AppNamespace
>
findPublicAppNamespaces
()
{
...
@@ -67,9 +74,10 @@ public class NamespaceController {
...
@@ -67,9 +74,10 @@ public class NamespaceController {
checkModel
(!
CollectionUtils
.
isEmpty
(
models
));
checkModel
(!
CollectionUtils
.
isEmpty
(
models
));
roleInitializationService
.
initNamespaceRoles
(
appId
,
models
.
get
(
0
).
getNamespace
().
getNamespaceName
());
roleInitializationService
.
initNamespaceRoles
(
appId
,
models
.
get
(
0
).
getNamespace
().
getNamespaceName
());
String
namespaceName
=
null
;
for
(
NamespaceCreationModel
model
:
models
)
{
for
(
NamespaceCreationModel
model
:
models
)
{
NamespaceDTO
namespace
=
model
.
getNamespace
();
NamespaceDTO
namespace
=
model
.
getNamespace
();
namespaceName
=
namespace
.
getNamespaceName
();
RequestPrecondition
RequestPrecondition
.
checkArgumentsNotEmpty
(
model
.
getEnv
(),
namespace
.
getAppId
(),
namespace
.
getClusterName
(),
namespace
.
getNamespaceName
());
.
checkArgumentsNotEmpty
(
model
.
getEnv
(),
namespace
.
getAppId
(),
namespace
.
getClusterName
(),
namespace
.
getNamespaceName
());
...
@@ -82,6 +90,14 @@ public class NamespaceController {
...
@@ -82,6 +90,14 @@ public class NamespaceController {
String
.
format
(
"create namespace fail. (env=%s namespace=%s)"
,
model
.
getEnv
(),
namespace
.
getNamespaceName
()),
e
);
String
.
format
(
"create namespace fail. (env=%s namespace=%s)"
,
model
.
getEnv
(),
namespace
.
getNamespaceName
()),
e
);
}
}
}
}
//default assign modify、release namespace role to namespace creator
String
loginUser
=
userInfoHolder
.
getUser
().
getUserId
();
rolePermissionService
.
assignRoleToUsers
(
RoleUtils
.
buildNamespaceRoleName
(
appId
,
namespaceName
,
RoleType
.
MODIFY_NAMESPACE
),
Sets
.
newHashSet
(
loginUser
),
loginUser
);
rolePermissionService
.
assignRoleToUsers
(
RoleUtils
.
buildNamespaceRoleName
(
appId
,
namespaceName
,
RoleType
.
RELEASE_NAMESPACE
),
Sets
.
newHashSet
(
loginUser
),
loginUser
);
return
ResponseEntity
.
ok
().
build
();
return
ResponseEntity
.
ok
().
build
();
}
}
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/RoleInitializationService.java
View file @
40ef0bd1
...
@@ -8,6 +8,7 @@ import com.ctrip.framework.apollo.common.entity.App;
...
@@ -8,6 +8,7 @@ import com.ctrip.framework.apollo.common.entity.App;
import
com.ctrip.framework.apollo.core.ConfigConsts
;
import
com.ctrip.framework.apollo.core.ConfigConsts
;
import
com.ctrip.framework.apollo.portal.auth.UserInfoHolder
;
import
com.ctrip.framework.apollo.portal.auth.UserInfoHolder
;
import
com.ctrip.framework.apollo.portal.constant.PermissionType
;
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.Permission
;
import
com.ctrip.framework.apollo.portal.entity.po.Role
;
import
com.ctrip.framework.apollo.portal.entity.po.Role
;
import
com.ctrip.framework.apollo.portal.util.RoleUtils
;
import
com.ctrip.framework.apollo.portal.util.RoleUtils
;
...
@@ -36,17 +37,23 @@ public class RoleInitializationService {
...
@@ -36,17 +37,23 @@ public class RoleInitializationService {
if
(
rolePermissionService
.
findRoleByRoleName
(
appMasterRoleName
)
!=
null
)
{
if
(
rolePermissionService
.
findRoleByRoleName
(
appMasterRoleName
)
!=
null
)
{
return
;
return
;
}
}
String
operat
erUserId
=
userInfoHolder
.
getUser
().
getUserId
();
String
operat
or
=
userInfoHolder
.
getUser
().
getUserId
();
//create app permissions
//create app permissions
createAppMasterRole
(
appId
);
createAppMasterRole
(
appId
);
//assign master role to user
//assign master role to user
rolePermissionService
rolePermissionService
.
assignRoleToUsers
(
RoleUtils
.
buildAppMasterRoleName
(
appId
),
Sets
.
newHashSet
(
app
.
getOwnerName
()),
.
assignRoleToUsers
(
RoleUtils
.
buildAppMasterRoleName
(
appId
),
Sets
.
newHashSet
(
app
.
getOwnerName
()),
operat
erUserId
);
operat
or
);
initNamespaceRoles
(
appId
,
ConfigConsts
.
NAMESPACE_APPLICATION
);
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
@Transactional
...
...
apollo-portal/src/main/resources/static/styles/common-style.css
View file @
40ef0bd1
...
@@ -262,10 +262,6 @@ table th {
...
@@ -262,10 +262,6 @@ table th {
font-size
:
13px
;
font-size
:
13px
;
}
}
.config-item-container
{
padding-top
:
19px
;
}
.config-item-container
.panel
{
.config-item-container
.panel
{
border-radius
:
0
;
border-radius
:
0
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment