Initial Dever 0.0.1
This commit is contained in:
commit
81233d098c
1479 files changed
+163782
No files matched your search
@@ -0,0 +1,14 @@
|
||||
# item
|
||||
|
||||
本领域的职责与行为见主题说明;函数签名和调用关系从源码读取。
|
||||
|
||||
## 说明
|
||||
|
||||
- [租户 HTTP 入口](doc/api-admin-entry.md)
|
||||
- [租户自动 REST](doc/api-admin-resource.md)
|
||||
- [显式租户命令](doc/api.md)
|
||||
- [租户业务验收](doc/app.md)
|
||||
- [租户持久任务](doc/job.md)
|
||||
- [租户条目](doc/model.md)
|
||||
|
||||
[调用流程](link.md)由 `dever inspect . --links` 生成。
|
||||
@@ -0,0 +1,5 @@
|
||||
cmd create = app.create
|
||||
|
||||
cmd count = app.count
|
||||
|
||||
cmd submit = app.submit
|
||||
@@ -0,0 +1,13 @@
|
||||
get count = app.count
|
||||
|
||||
post add = app.create
|
||||
|
||||
post submit = app.submit
|
||||
|
||||
post register = app.register
|
||||
|
||||
post remove = app.remove
|
||||
|
||||
authenticated get permissions = app.permissions
|
||||
|
||||
public get health = app.health
|
||||
@@ -0,0 +1 @@
|
||||
rest model
|
||||
@@ -0,0 +1,22 @@
|
||||
type Work { title: Text }
|
||||
|
||||
create(title: Text) (id: model.id) {
|
||||
item = model.create({ title = title })
|
||||
id = item.id
|
||||
}
|
||||
|
||||
count() (total: Int) { total = model.count() }
|
||||
|
||||
submit(title: Text, key: Text) (id: Id) {
|
||||
id = dever.job.enqueue(job.apply, Work { title = title }, key)
|
||||
}
|
||||
|
||||
apply(input: Work) () { created = create(input.title) }
|
||||
|
||||
register(id: Uuid) (key: Text) { key = dever.auth.registerCapability(id) }
|
||||
|
||||
remove(id: Uuid) () { dever.auth.removeCapability(id) }
|
||||
|
||||
permissions() (entries: List<dever.auth.Permission>) { entries = dever.auth.permissions() }
|
||||
|
||||
health() (ready: Bool) { ready = true }
|
||||
@@ -0,0 +1,31 @@
|
||||
# 租户 HTTP 入口
|
||||
|
||||
用于自有临时数据库的租户隔离与原生执行验收。
|
||||
|
||||
### count
|
||||
|
||||
读取当前租户。
|
||||
|
||||
### add
|
||||
|
||||
受保护的业务写入。
|
||||
|
||||
### submit
|
||||
|
||||
受保护入口建立任务执行身份。
|
||||
|
||||
### register
|
||||
|
||||
登记当前命名空间能力。
|
||||
|
||||
### remove
|
||||
|
||||
撤销当前命名空间能力。
|
||||
|
||||
### permissions
|
||||
|
||||
可信身份可读权限目录。
|
||||
|
||||
### health
|
||||
|
||||
纯值入口仍可公开。
|
||||
@@ -0,0 +1,7 @@
|
||||
# 租户自动 REST
|
||||
|
||||
用于自有临时数据库的租户隔离与原生执行验收。
|
||||
|
||||
### resource
|
||||
|
||||
使用默认领域 Model。
|
||||
@@ -0,0 +1,15 @@
|
||||
# 显式租户命令
|
||||
|
||||
用于自有临时数据库的租户隔离与原生执行验收。
|
||||
|
||||
### create
|
||||
|
||||
创建本机选择租户的记录。
|
||||
|
||||
### count
|
||||
|
||||
统计本机选择租户的记录。
|
||||
|
||||
### submit
|
||||
|
||||
显式 System 身份提交租户任务。
|
||||
@@ -0,0 +1,67 @@
|
||||
# 租户业务验收
|
||||
|
||||
用于自有临时数据库的租户隔离与原生执行验收。
|
||||
|
||||
## news.item.Work
|
||||
|
||||
任务数据没有身份能力。
|
||||
|
||||
字段:`title`:标题
|
||||
|
||||
## news.item.create
|
||||
|
||||
创建当前物理租户内的条目。
|
||||
|
||||
输入:`title`:标题
|
||||
输出:`id`:编号
|
||||
|
||||
## news.item.count
|
||||
|
||||
统计当前物理租户。
|
||||
|
||||
输入:无
|
||||
输出:`total`:数量
|
||||
|
||||
## news.item.submit
|
||||
|
||||
任务继承入口建立的执行身份。
|
||||
|
||||
输入:
|
||||
- `title`:标题
|
||||
- `key`:幂等键
|
||||
输出:`id`:任务编号
|
||||
|
||||
## news.item.apply
|
||||
|
||||
在任务事务中创建业务记录。
|
||||
|
||||
输入:`input`:任务数据
|
||||
输出:无
|
||||
|
||||
## news.item.register
|
||||
|
||||
在已鉴权入口命名空间中登记业务权限。
|
||||
|
||||
输入:`id`:业务编号
|
||||
输出:`key`:权限键
|
||||
|
||||
## news.item.remove
|
||||
|
||||
移除权限及关联授权。
|
||||
|
||||
输入:`id`:业务编号
|
||||
输出:无
|
||||
|
||||
## news.item.permissions
|
||||
|
||||
合并当前站点的静态与租户业务权限。
|
||||
|
||||
输入:无
|
||||
输出:`entries`:目录
|
||||
|
||||
## news.item.health
|
||||
|
||||
同租户组件的纯值公开入口不访问租户存储。
|
||||
|
||||
输入:无
|
||||
输出:`ready`:状态
|
||||
@@ -0,0 +1,14 @@
|
||||
# 租户持久任务
|
||||
|
||||
用于自有临时数据库的租户隔离与原生执行验收。
|
||||
|
||||
### database
|
||||
|
||||
队列和业务使用同一物理连接。
|
||||
|
||||
## news.item.job.apply
|
||||
|
||||
静态调用同领域 App。
|
||||
|
||||
输入:`input`:数据
|
||||
输出:无
|
||||
@@ -0,0 +1,9 @@
|
||||
# 租户条目
|
||||
|
||||
用于自有临时数据库的租户隔离与原生执行验收。
|
||||
|
||||
## news.item.model.Item
|
||||
|
||||
两个租户可以使用相同唯一标题。
|
||||
|
||||
字段:`title`:标题
|
||||
@@ -0,0 +1,3 @@
|
||||
database default
|
||||
|
||||
job apply(input: app.Work) () retry(1) timeout(1000) { app.apply(input) }
|
||||
@@ -0,0 +1 @@
|
||||
type Item { title: Text unique }
|
||||
@@ -0,0 +1,11 @@
|
||||
# account
|
||||
|
||||
本领域的职责与行为见主题说明;函数签名和调用关系从源码读取。
|
||||
|
||||
## 说明
|
||||
|
||||
- [平台初始化命令](doc/api.md)
|
||||
- [租户身份验证](doc/app.md)
|
||||
- [全局测试账号](doc/model.md)
|
||||
|
||||
[调用流程](link.md)由 `dever inspect . --links` 生成。
|
||||
@@ -0,0 +1 @@
|
||||
cmd seed = app.seed
|
||||
@@ -0,0 +1,23 @@
|
||||
type Identity { id: Text
|
||||
user_id: model.id?
|
||||
tenant_id: model.id? }
|
||||
|
||||
verify(claims: dever.auth.Claims) (verified: Identity) {
|
||||
account = model.first({ where = subject == claims.subject and session == claims.session })
|
||||
verified = identity(account, claims.tenant)
|
||||
}
|
||||
|
||||
identity(account: model.Account, tenant: Text) (verified: Identity) {
|
||||
require(account.subject == tenant)
|
||||
verified = Identity { id = account.subject, user_id = account.id, tenant_id = account.id }
|
||||
}
|
||||
identity(account: null, tenant: Text?) (verified: Identity) { fail(dever.api.Error.Unauthorized) }
|
||||
identity(account: model.Account, tenant: null) (verified: Identity) { fail(dever.api.Error.Unauthorized) }
|
||||
|
||||
require(value: true) () {}
|
||||
require(value: false) () { fail(dever.api.Error.Unauthorized) }
|
||||
|
||||
seed(subject: Text, session: Text) (id: model.id) {
|
||||
account = model.create({ subject = subject, session = session })
|
||||
id = account.id
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
# 平台初始化命令
|
||||
|
||||
用于自有临时数据库的租户隔离与原生执行验收。
|
||||
|
||||
### seed
|
||||
|
||||
不需要租户身份的全局初始化。
|
||||
@@ -0,0 +1,44 @@
|
||||
# 租户身份验证
|
||||
|
||||
用于自有临时数据库的租户隔离与原生执行验收。
|
||||
|
||||
## platform.account.Identity
|
||||
|
||||
此测试把一个全局账号映射为一个内部租户。
|
||||
|
||||
字段:
|
||||
- `id`:主体
|
||||
- `user_id`:用户
|
||||
- `tenant_id`:内部租户
|
||||
|
||||
## platform.account.verify
|
||||
|
||||
每次请求与 Job 都重查全局账号。
|
||||
|
||||
输入:`claims`:签名后的声明
|
||||
输出:`verified`:可信身份
|
||||
|
||||
## platform.account.identity
|
||||
|
||||
外部租户声明必须属于当前账号。
|
||||
|
||||
输入:
|
||||
- `account`:账号
|
||||
- `tenant`:外部声明
|
||||
输出:`verified`:可信身份
|
||||
|
||||
## platform.account.require
|
||||
|
||||
明确拒绝无效成员关系。
|
||||
|
||||
输入:`value`:校验结果
|
||||
输出:无
|
||||
|
||||
## platform.account.seed
|
||||
|
||||
只允许本机命令创建测试账号。
|
||||
|
||||
输入:
|
||||
- `subject`:主体
|
||||
- `session`:会话
|
||||
输出:`id`:内部编号
|
||||
@@ -0,0 +1,11 @@
|
||||
# 全局测试账号
|
||||
|
||||
用于自有临时数据库的租户隔离与原生执行验收。
|
||||
|
||||
## platform.account.model.Account
|
||||
|
||||
仅存在于测试控制库。
|
||||
|
||||
字段:
|
||||
- `subject`:账号与外部租户声明
|
||||
- `session`:测试会话
|
||||
@@ -0,0 +1,2 @@
|
||||
global type Account { subject: Text unique
|
||||
session: Text }
|
||||
Reference in new issue
Block a user