Files
marqdo/ext/security/index.mq.md
T
cflmy 9331af78e2 release(2.8.0): 合入 CHANGELOG/README/发版说明/skills prove 任务;CI 链接指向 doc/releases
- CHANGELOG.md:v2.8.0 条目(中英双语);
- README.md:版本行 2.7.1→2.8.0 + 愿景第 6 条(知识可证明);
- doc/releases/v2.8.0.md:双语发版说明(亮点/用法/已知限制);
- skills/marqdo-dev/index.mq.md:新增 prove 任务(路径/目录模式/
  require_lean/json;参数用 + 行声明升参,check 与 narrative-ratio 通过);
- 设计文档 §12.5 标记已合入;发版链接统一指向 doc/releases/v2.8.0.md。
2026-11-18 10:29:26 +08:00

52 lines
3.0 KiB
Markdown
Executable File

---
markup: occlusion
title: Security resources — authentication, roles and OIDC
import:
permissions_api: ext/security/rbac.mq.md
---
Use [auth](auth.mq.md) for credential/session operations, [rbac](rbac.mq.md) for role permissions,
and [OIDC](oidc.mq.md) for attaching an external identity provider to an existing web app.
[Tenant selection](tenant.mq.md) supplies explicit request context for scoped data queries;
it does not authenticate a subject or prove tenant membership.
中文服务工作流使用[鉴权绑定](鉴权.mq.md),与 auth.attach 保持相同策略及默认值。
Endpoint authorization remains explicit in the web artifact metadata; a script permission check
does not automatically protect an HTTP route.
The resources use the native web plugin. Build it with scripts/build-web-plugin.sh in this checkout.
This entry's deterministic permission check does not contact an identity provider or change users:
```sh
marqdo call ext/security/index.mq.md check_permission 'held="notes:read"' 'needed="notes:read"' --effects plugin --json
```
Constructors create receivers that are used by resource methods. The free function below makes
that pattern available to CLI callers without copying opaque object fields. For OIDC, configure
registered callback URLs and origin restrictions in oidc.mq.md; never copy production credentials
into a source example. Transport success and authorization success are distinct fields.
Develop native security policy in the existing web security implementation, then document the
public contract and exercise both allow and deny cases. Keep permission delimiters, wildcard
behavior, session lifetime and credential handling explicit. Use local fixtures for login and
OIDC tests; the reusable source must not require a live identity service merely to be inspected.
## check_permission
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| held | text | required | Comma-separated permissions held by the subject; wildcard follows the native RBAC policy |
| needed | text | required | Comma-separated required permissions interpreted by the documented RBAC checker |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Native ok/allowed record; inspect allowed to decide authorization |
The inputs `held` and `needed` describe one explicit permission decision, not a role assignment
or a request to modify the user database. The native checker currently accepts any matching
required permission; held wildcard permits all. Use the leaf API when changing a role catalog.
The checker is an associated tool: it does not read self, so this workflow calls its definition
path directly rather than pretending it is an instance method. We return *[Evaluate this subject against the requested permission set](permissions_api.rbac.can(permissions=`held`, needed=`needed`))* .
The returned allowed field is the authorization decision; the outer CLI ok only reports whether
this function call completed. A denied decision remains a valid, observable result.