未验证 提交 d194fc81 编写于 作者: S shendongdong 提交者: GitHub

fix workflow create auth error (#2961)

* fix workflow create auth error
Signed-off-by: Nallenshen <shendongdong@koderover.com>

* fix workflow create auth error
Signed-off-by: Nallenshen <shendongdong@koderover.com>

* update project key
Signed-off-by: Nallenshen <shendongdong@koderover.com>

* remove debug log
Signed-off-by: Nallenshen <shendongdong@koderover.com>

---------
Signed-off-by: Nallenshen <shendongdong@koderover.com>
上级 72478c8a
...@@ -41,10 +41,17 @@ func GetWorkflowTemplateByID(c *gin.Context) { ...@@ -41,10 +41,17 @@ func GetWorkflowTemplateByID(c *gin.Context) {
// authorization check // authorization check
if !ctx.Resources.IsSystemAdmin { if !ctx.Resources.IsSystemAdmin {
if !ctx.Resources.SystemActions.Template.View { if !ctx.Resources.SystemActions.Template.View {
projectKey := c.Param("projectName")
if _, ok := ctx.Resources.ProjectAuthInfo[projectKey]; !ok {
ctx.UnAuthorized = true ctx.UnAuthorized = true
internalhandler.JSONResponse(c, ctx)
return return
} }
if !ctx.Resources.ProjectAuthInfo[projectKey].IsProjectAdmin &&
!ctx.Resources.ProjectAuthInfo[projectKey].Workflow.Create {
ctx.UnAuthorized = true
return
}
}
} }
resp, err := templateservice.GetWorkflowTemplateByID(c.Param("id"), ctx.Logger) resp, err := templateservice.GetWorkflowTemplateByID(c.Param("id"), ctx.Logger)
...@@ -70,9 +77,17 @@ func ListWorkflowTemplate(c *gin.Context) { ...@@ -70,9 +77,17 @@ func ListWorkflowTemplate(c *gin.Context) {
// authorization check // authorization check
if !ctx.Resources.IsSystemAdmin { if !ctx.Resources.IsSystemAdmin {
if !ctx.Resources.SystemActions.Template.View { if !ctx.Resources.SystemActions.Template.View {
projectKey := c.Param("projectName")
if _, ok := ctx.Resources.ProjectAuthInfo[projectKey]; !ok {
ctx.UnAuthorized = true ctx.UnAuthorized = true
return return
} }
if !ctx.Resources.ProjectAuthInfo[projectKey].IsProjectAdmin &&
!ctx.Resources.ProjectAuthInfo[projectKey].Workflow.Create {
ctx.UnAuthorized = true
return
}
}
} }
excludeBuildIn := false excludeBuildIn := false
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册