ext/web P3: RBAC, audit timestamps, FK, gallery, ETag
Complete the remaining network-extension gaps so media sites can gate by role, auto-stamp rows, declare foreign keys, browse uploads, and conditional-get downloads. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
2d51f29199
commit
c6360adccb
13 files changed
+938
-35
No files matched your search
+23
-4
@@ -151,7 +151,7 @@ Open a database handle. URL schemes: `sqlite:path` (default), `postgres://…` /
|
||||
+ `name`
|
||||
+ `fields`
|
||||
|
||||
Create a table from a schema table. Optional columns: `唯一`/`unique`, `索引`/`index` (creates UNIQUE / INDEX).
|
||||
Create a table from a schema table. Optional columns: `唯一`/`unique`, `索引`/`index` (creates UNIQUE / INDEX), `外键`/`fk`/`references` (e.g. `posts.id` or `posts(id)`). Columns named `created_at` / `updated_at` are filled automatically on insert/update when present.
|
||||
|
||||
*url = self[^url]*
|
||||
**> web_db_init url=`url` name=`name` fields=`fields`**
|
||||
@@ -467,10 +467,29 @@ Register a WebSocket endpoint at `path` (e.g. `/live`). `mode` is `echo` (defaul
|
||||
+ `users`
|
||||
+ `session_ttl`=3600
|
||||
|
||||
Keep the app's `admin=True`, and gate `/admin*` behind a login page. `users` is an admin-users table (`|username|password|` / `|用户名|密码|`); unauthenticated requests redirect to `/admin/login`.
|
||||
Keep the app's `admin=True`, and gate `/admin*` behind a login page. `users` is an admin-users table (`|username|password|` / `|用户名|密码|`); optional `role` / `角色` column (`admin` / `author` / `visitor`). Unauthenticated requests redirect to `/admin/login`. Registers a default gate `/admin*` → `admin`.
|
||||
|
||||
**> web_app_auth app=`self` users=`users` session_ttl=`session_ttl`**
|
||||
|
||||
## gate
|
||||
+ `path`
|
||||
+ `roles`=admin
|
||||
|
||||
Require one of `roles` (CSV) for `path` (prefix or `path*`). Anonymous sessions count as `visitor`.
|
||||
|
||||
**> web_app_gate app=`self` path=`path` roles=`roles`**
|
||||
|
||||
## gallery
|
||||
+ `path`=/gallery
|
||||
+ `storage`
|
||||
+ `prefix`=uploads/
|
||||
+ `title`=Gallery
|
||||
+ `download_base`=/_media
|
||||
|
||||
Serve an HTML media gallery listing objects under `prefix` in `storage`, linking through `download_base`.
|
||||
|
||||
**> web_app_gallery app=`self` path=`path` storage=`storage` prefix=`prefix` title=`title` download_base=`download_base`**
|
||||
|
||||
## route_rss
|
||||
+ `path`
|
||||
+ `table`
|
||||
@@ -555,7 +574,7 @@ Session/auth helper. Constructs a config object; `login` validates against the u
|
||||
+ `username`
|
||||
+ `password`
|
||||
|
||||
Validate credentials against the users table and create a session. Returns `{ok, session_id, username}`.
|
||||
Validate credentials against the users table and create a session. Returns `{ok, session_id, username, role}`.
|
||||
|
||||
*users = self[^users]*
|
||||
*ttl = self[^session_ttl]*
|
||||
@@ -564,7 +583,7 @@ Validate credentials against the users table and create a session. Returns `{ok,
|
||||
## check
|
||||
+ `session_id`
|
||||
|
||||
Returns `{ok, username}` when the session is valid.
|
||||
Returns `{ok, username, role}` when the session is valid.
|
||||
|
||||
**> web_auth_check session_id=`session_id`**
|
||||
|
||||
|
||||
+21
-2
@@ -138,7 +138,7 @@ SEO / OpenGraph 元数据表(`|键|值|`)。如 `title`、`description`、`c
|
||||
+ `名`
|
||||
+ `字段`
|
||||
|
||||
从表结构创建表。可选列:`唯一`/`unique`、`索引`/`index`。
|
||||
从表结构创建表。可选列:`唯一`/`unique`、`索引`/`index`、`外键`/`fk`/`references`(如 `posts.id`)。若存在 `created_at` / `updated_at` 列,插入/更新时自动写入。
|
||||
|
||||
*url = self[^url]*
|
||||
**> web_db_init url=`url` name=`名` fields=`字段`**
|
||||
@@ -449,10 +449,29 @@ SEO / OpenGraph 元数据表(`|键|值|`)。如 `title`、`description`、`c
|
||||
+ `用户表`
|
||||
+ `会话时长`=3600
|
||||
|
||||
在保持 `后台=真` 的同时,为 `/admin*` 加登录门禁。`用户表` 是管理员表(`|用户名|密码|`);未登录请求重定向到 `/admin/login`。
|
||||
在保持 `后台=真` 的同时,为 `/admin*` 加登录门禁。`用户表` 为 `|用户名|密码|`(可选 `角色`:`admin`/`author`/`visitor`);未登录重定向到 `/admin/login`。默认登记门禁 `/admin*` → `admin`。
|
||||
|
||||
**> web_app_auth app=`self` users=`用户表` session_ttl=`会话时长`**
|
||||
|
||||
## 门禁
|
||||
+ `路径`
|
||||
+ `角色`=admin
|
||||
|
||||
要求会话角色落在 `角色`(CSV)之一才可访问 `路径`(前缀或 `路径*`)。匿名视为 `visitor`。
|
||||
|
||||
**> web_app_gate app=`self` path=`路径` roles=`角色`**
|
||||
|
||||
## 相册
|
||||
+ `路径`=/gallery
|
||||
+ `存储`
|
||||
+ `前缀`=uploads/
|
||||
+ `标题`=相册
|
||||
+ `下载基址`=/_media
|
||||
|
||||
列出 `存储` 下 `前缀` 对象,生成 HTML 相册页,链接走 `下载基址`。
|
||||
|
||||
**> web_app_gallery app=`self` path=`路径` storage=`存储` prefix=`前缀` title=`标题` download_base=`下载基址`**
|
||||
|
||||
## 路由订阅
|
||||
+ `路径`
|
||||
+ `表`
|
||||
|
||||
Reference in new issue
Block a user