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:
1 parent
27991a7822
commit
5cf84fe9b7
27 files changed
+2372
-80
No files matched your search
@@ -0,0 +1,33 @@
|
||||
---
|
||||
title: web-tenant-saas demo
|
||||
description: Dual-tenant isolation via ?t= query + tenant_scope JSON API.
|
||||
import web:ext/web/web.mq.md
|
||||
---
|
||||
|
||||
# main
|
||||
|
||||
`items_schema` =
|
||||
|
||||
| name | type | nullable |
|
||||
|------|------|----------|
|
||||
| id | integer | false |
|
||||
| title | text | false |
|
||||
| tenant_id | text | false |
|
||||
|
||||
`api` =
|
||||
|
||||
| path | method | table | order | limit | tenant_scope |
|
||||
|------|--------|-------|-------|-------|--------------|
|
||||
| api/items | GET | items | id | 50 | true |
|
||||
|
||||
**db = > web.db url="sqlite:data/tenant-saas.db"**
|
||||
> `db`.init name=items fields=`items_schema`
|
||||
> `db`.exec sql="DELETE FROM items"
|
||||
> `db`.exec sql="INSERT INTO items(title, tenant_id) VALUES('Acme note','acme')"
|
||||
> `db`.exec sql="INSERT INTO items(title, tenant_id) VALUES('Beta note','beta')"
|
||||
|
||||
**page = > web.page title="Tenant SaaS" intro="<p>Try <a href='/api/items?t=acme'>/api/items?t=acme</a> vs <a href='/api/items?t=beta'>/api/items?t=beta</a>.</p>"**
|
||||
**app = > web.app page=`page` db=`db` host="127.0.0.1" port=18092 admin=False**
|
||||
**app = > `app`.tenant mode="path" param="t" default_scope=False**
|
||||
**app = > `app`.configure json=`api`**
|
||||
> `app`.listen
|
||||
@@ -0,0 +1,12 @@
|
||||
---
|
||||
title: web-ws-room demo
|
||||
description: Dynamic room WS with presence (G-WS1/2 bag). Open / and connect via bridge or wscat.
|
||||
import web:ext/web/web.mq.md
|
||||
---
|
||||
|
||||
# main
|
||||
|
||||
**page = > web.page title="WS room" intro="<p class='lede'>Chat room <code>lobby</code> via <code>/chat/lobby</code>. Presence joins <code>chat.room.lobby.presence</code>.</p><pre id='log'></pre>"**
|
||||
**app = > web.app page=`page` host="127.0.0.1" port=18091 admin=False**
|
||||
**app = > `app`.route_ws path="/chat/{id}" mode="room" room_key="chat.room.{id}" presence=True**
|
||||
> `app`.listen
|
||||
Reference in new issue
Block a user