server: 平台抽象层+bilibili、服务端加密凭据库、角色中间件;web: 精简页面/路由、macOS 客户端(Swift)与多份方案文档;移除误入库的编译产物
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"everypublish/server/internal/api/response"
|
||||
)
|
||||
|
||||
// WorkspaceRoles enforces the member role from the current JWT. Resource
|
||||
// handlers still apply workspace_id predicates; this middleware only handles
|
||||
// the action-level permission boundary.
|
||||
func WorkspaceRoles(roles ...string) gin.HandlerFunc {
|
||||
allowed := make(map[string]struct{}, len(roles))
|
||||
for _, role := range roles {
|
||||
allowed[role] = struct{}{}
|
||||
}
|
||||
return func(c *gin.Context) {
|
||||
if _, ok := allowed[c.GetString("mrole")]; !ok {
|
||||
response.Fail(c, http.StatusForbidden, 1003, "当前角色无权执行此操作")
|
||||
c.Abort()
|
||||
return
|
||||
}
|
||||
c.Next()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user