feat(web): RBAC, tenant scope, and WS room hooks

Add configurable role⊥permission (five tables, gate permissions, register,
/_rbac desk), multi-tenant path/header resolution with JSON tenant_scope,
and route_ws on_message/presence/dynamic room_key — with author surfaces,
demos, and smokes.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
cflmyandCursor committed 2026-09-17 20:54:02 +08:00
1 parent 27991a7822
commit 5cf84fe9b7
27 files changed
+2372 -80

No files matched your search

+16 -7
View File
@@ -34,12 +34,13 @@ type CORSConfig struct {
// JSONRouteMount is one JSON API route with leading-slash path.
type JSONRouteMount struct {
Path string
Method string
Table string
Where any
Order string
Limit int64
Path string
Method string
Table string
Where any
Order string
Limit int64
TenantScope bool
}
// Configure merges configure tables into app.middleware (Rust web_app_middleware).
@@ -178,6 +179,11 @@ func parseJSONRoute(path string, spec any) (JSONRouteMount, bool) {
if w, ok := m["where"]; ok && w != nil {
r.Where = w
}
if v, ok := m["tenant_scope"]; ok {
r.TenantScope = boolish(v)
} else if v, ok := m["租户作用域"]; ok {
r.TenantScope = boolish(v)
}
return r, true
}
@@ -255,7 +261,7 @@ func SecurityFromTable(tableV any) map[string]any {
return out
}
// JSONRoutesFromTable normalizes `|路径|方法|表|条件|排序|上限|` into json_routes.
// JSONRoutesFromTable normalizes `|路径|方法|表|条件|排序|上限|租户作用域|` into json_routes.
func JSONRoutesFromTable(tableV any) map[string]any {
rows, _ := table.AsRows(tableV).([]any)
out := map[string]any{}
@@ -291,6 +297,9 @@ func JSONRoutesFromTable(tableV any) map[string]any {
if order != "" {
spec["order"] = order
}
if scope := col(m, "租户作用域", "tenant_scope", "TenantScope"); scope != "" {
spec["tenant_scope"] = boolish(scope)
}
out[path] = spec
}
return out