开发修复:收紧域名读取并保护任务创建竞态
更新域名改用项目可见资源读取;任务创建在事务中锁定所属域名,和删除流程共用资源锁,防止删除检查后的在途任务竞态。
This commit is contained in:
1 parent
68bf2b9838
commit
82448c9ad1
4 files changed
+69
-21
No files matched your search
@@ -602,7 +602,7 @@ func (s *Server) createDomain(c *gin.Context) {
|
||||
}
|
||||
|
||||
func (s *Server) updateDomain(c *gin.Context) {
|
||||
if !s.requireProjectDomainRepository(c) || !s.requireDomainRepository(c) {
|
||||
if !s.requireProjectDomainRepository(c) || !s.requireProjectResourceReader(c) {
|
||||
return
|
||||
}
|
||||
var request domainRequest
|
||||
@@ -610,13 +610,9 @@ func (s *Server) updateDomain(c *gin.Context) {
|
||||
s.writeError(c, http.StatusBadRequest, "请求参数无效", err)
|
||||
return
|
||||
}
|
||||
existing, err := s.repository.GetByID(c.Request.Context(), c.Param("id"))
|
||||
existing, err := s.projectResources.GetVisibleDomain(c.Request.Context(), c.GetString(authenticatedActorKey), c.Param("id"))
|
||||
if err != nil {
|
||||
if repository.IsNotFound(err) {
|
||||
s.writeError(c, http.StatusNotFound, "域名不存在", err)
|
||||
return
|
||||
}
|
||||
s.writeError(c, http.StatusInternalServerError, "读取域名失败", err)
|
||||
s.writeProjectResourceError(c, err)
|
||||
return
|
||||
}
|
||||
if !s.authorizeDomainMutation(c, existing.ProjectID) {
|
||||
|
||||
Reference in new issue
Block a user