sqlite-web 0.7.2
gitea.db
package_version
Create
Query
access
access_token
action
action_artifact
action_run
action_run_index
action_run_job
action_runner
action_runner_token
action_schedule
action_schedule_spec
action_task
action_task_output
action_task_step
action_tasks_version
action_variable
app_state
attachment
auth_token
badge
branch
collaboration
comment
commit_status
commit_status_index
commit_status_summary
commit_sync_log
commit_sync_status
dbfs_data
dbfs_meta
deploy_key
email_address
email_hash
external_login_user
follow
gpg_key
gpg_key_import
hook_task
issue
issue_assignees
issue_content_history
issue_dependency
issue_index
issue_label
issue_pin
issue_user
issue_watch
label
language_stat
lfs_lock
lfs_meta_object
login_source
milestone
mirror
notice
notification
oauth2_application
oauth2_authorization_code
oauth2_grant
org_user
package
package_blob
package_blob_upload
package_cleanup_rule
package_file
package_property
package_version
project
project_board
project_issue
protected_branch
protected_tag
public_key
pull_auto_merge
pull_request
push_mirror
reaction
release
renamed_branch
repo_archiver
repo_hidden_file
repo_indexer_status
repo_license
repo_redirect
repo_topic
repo_transfer
repo_unit
repository
review
review_state
secret
session
sqlite_sequence
star
stopwatch
system_setting
task
team
team_invite
team_repo
team_unit
team_user
topic
tracked_time
two_factor
upload
user
user_badge
user_blocking
user_open_id
user_redirect
user_setting
version
watch
webauthn_credential
webhook
Toggle helper tables
Structure
Content
Query
Insert
Drop
Import
Export
Update row 42 in package_version
id
Primary key.
INTEGER NOT NULL
package_id
INTEGER NOT NULL
creator_id
INTEGER NOT NULL (default 0
version
1.0.0-rc.7
TEXT NOT NULL
lower_version
1.0.0-rc.7
TEXT NOT NULL
created_unix
INTEGER NOT NULL
is_internal
INTEGER NOT NULL (default 0
metadata_json
{"scope":"@juhai","name":"client-identity","description":"企业 IdP human access token 消费者:固定信任、JWKS 缓存、严格 claims 与 UserInfo 撤销回查","license":"UNLICENSED","dependencies":{"ajv":"8.20.0","jose":"6.2.10"},"development_dependencies":{"@juhai/kernel":"0.24.0","@types/node":"22.19.20","typescript":"5.9.3","vitest":"2.1.9"},"peer_dependencies":{"@juhai/kernel":"0.24.0"},"readme":"# @juhai/client-identity\n\nPF-07 阶段 2 ⑥:企业 IdP **human access token** 的框架无关消费者。Node.js ≥ 20.19,ESM。\n服务身份 / AI Token、IdP 模块迁移和应用接线仍是后续工作;本包不签发 Token、不实现权限引擎。\n\n```ts\nimport { createIdentityClient } from \"@juhai/client-identity\";\n\n// 在应用装配时创建一次,issuer 和 audience 来自受控配置。\nconst identity = createIdentityClient({\n issuers: [\"https://idp.example.com/t/acme\"],\n audience: \"my-app\",\n});\nconst result = await identity.verifyHumanAccessToken(accessToken, {\n tenantId: requestTenantHeader, // 可选,只与签名值比较,绝不作为租户来源\n requiredScopes: [\"openid\", \"material.read\"], // 路由声明,非请求体输入\n});\nif (!result.ok) return reply.status(result.status).send({ code: result.code });\n// HTTP、WS、SSE 适配器共同使用这一身份结果,不能自行解码 JWT 生成 principal。\nconst principal = result.identity;\n```\n\n每次成功都经过:固定 issuer map → 真实 RS256 签名 → 原始消费者 JSON Schema → 单值 audience / 时间 /\nscope 去重 / 租户与主体绑定 → 同 issuer 的 **`/oidc/userinfo`** 权威回查。公钥地址为\n`/oauth2/jwks`;两个路径取自当前 IdP Controller 与 Discovery 实现。UserInfo 要求 Token 含 `openid`。\n不采用请求输入中的 discovery URL、`jku` 或 `x5u`,不跟随重定向,不缓存 Token 的有效结论。\n\nJWKS 默认缓存 60 秒、未知 kid 刷新冷却 30 秒,单次 HTTP 超时 2 秒;密钥过期且上游不可用时失败关闭。\n轮换须先发布新公钥,再签新 Token,旧公钥覆盖存量 Token 生命周期。上游 UserInfo 401/403 → 本地 401;\n上游不可达、5xx、畸形响应或 subject 不一致 → 503。缺信任配置 → 503;Token/租户校验失败 → 401;\n主体冒充或缺路由要求的 scope → 403。只返回稳定错误码,不返回凭据、JOSE 原始错误或 UserInfo PII。\nHTTP 仅允许显式 `allowLoopbackHttp: true` 的回环开发地址;生产 issuer 使用 HTTPS。\n\n该回查证明**本次请求时** IdP 用户、会话、授权与 client 仍有效。它不自动关闭���建立的 WS/SSE,\n也不宣称实现跨应用撤销事件、快照缓存或 p95 SLA;调用方须重新校验长连接,后续再接权威失效流。\n额外 `roles` / `permissions` claim 不被映射为权限;此 API 不能将 human Token 提升为 service/AI。\n\n## 契约来源与发布边界\n\n`src/access-token.v1.schema.json` 原样导入现有 E0 消费者契约,是本包结构校验唯一来源;\n12 条原始夹具在 `runtime/modules/identity/test/fixtures/access-token.v1.fixtures.json`,\n文件摘要与来源见 `contract-import.json`。测试读取该套夹具,用本轮真实 RSA 密钥签名并经 HTTP 执行,\n不是只运行 JSON 分类器。原材料里的 pending 描述按导入快照保留,不作为最新裁决状态。\n\n该 profile 尚未登记为 `@juhai/contracts` 可导出的正式契约,因此本批不虚加该包依赖;\nCatalog 登记及新版本发布后,应改用其导出并移除临时副本。peer `@juhai/kernel` exact 0.24.0 保持 SDK\n版本约束,但内核当前没有 IdentityPort,本包不伪造 `createRemote\u003cPort\u003ePort` 或更改内核端口签名。\n包可构建/打包不等于已发布,Release Manifest 中非 null 也不代表应用接入或 PF-07 全部完成。\n\n## 验证\n\n`pnpm --dir runtime --filter @juhai/client-identity build`;`test` 使用临时回环 HTTP server,\n覆盖原始 12 条夹具、签名不符、JWKS 轮换与冷却、撤销、配置错误、超时、重定向、过期及主体冒充。\n这些测试不替代真实 IdP 数据库/浏览器验收,模块迁移后须再走实际登录与吊销链路。\n\nPF-08 canonical 切换:消费者额外要求 tenant_id 为 DEC-032 的 ten_ ULID,旧 UUID / 旧别名即使签名有效也拒绝。原始导入夹具与摘要保留;当前实现验收使用 `runtime/modules/identity/test/fixtures/canonical-access-token.fixtures.json`,同样保留原有签名、aud、scope 和头部拒绝场景,只将合法租户样本改为 canonical。此处只收紧标识格式,实时授权仍经 UserInfo 核验;实际 HR/OS 接入与正式分发版本另行交付。\n\n\nPF-08 候选解析客户端 `createTenantMappingClient({ issuers, timeoutMs })` 从固定 HTTPS issuer 列表选择 `/identity/tenant-resolution`。调用 `resolve(machineToken, { issuer, tenantRef, expectedCanonicalId })`;两项 canonical 必须一致,`expectedCanonicalId` 由宿主已验签的身份上下文提供。服务端检查 `idp:tenant:resolve` 及其配置的租户内 Application audience,不使用请求体提供的主体、应用或期望身份。\n\n客户端拒绝旧别名、重定向、超大响应、错误身份/版本/TTL,期限覆盖响应体,映射不缓存;未配置或依赖故障失败关闭。这里返回身份映射而非权限决策,机器 Token 验签与当前授权由下述独立机器身份客户端负责。协议仍为 CHG-004 候选,Registry 发布和真实 HR/OS 接入单独推进。旧别名只由管理面/迁移工具在明确到期窗口内解析,业务客户端不开放该选项。\n\n## 机器身份消费者(候选)\n\n`createMachineIdentityClient({ issuer, audience, authenticate })` 专门接受 M1 签发的 service/job access token。\n`audience` 必须是接收服务的 M1 Application.id;`authenticate(signal)` 提供接收服务自身的\n`client_secret_basic` 凭据或新生成的 `private_key_jwt` assertion。当前 M1 assertion audience 为\n`${issuer}/oauth2/token`,包括 introspection;不能重用旧 assertion,也不能用人类 Bearer 代替服务凭据。\n\n每次调用 `verifyMachineAccessToken(token, { tenantId, subject, appId, actorType, requiredScopes })`\n均从固定 issuer 读取公钥、验证 RS256 与精确声明,再通过经过服务认证的 introspection 查询当前令牌、\n授权和主体版本。无有效结论缓存,撤销后的下一次调用拒绝。错误令牌返回 401;请求主体/租户/应用/\n作用域不匹配返回 403;M1 或接收服务凭据不可用返回 503。只返回稳定错误码。\n\n整个公钥读���、验签、取接收服务凭据和 introspection 响应体共享默认 2 秒截止时间,每个响应最多\n64 KiB,禁止重定向。`close()` 取消进行中的调用并拒绝后续调用。忽略取消的外部回调可能继续运行,\n但迟到凭据不能发起 introspection,也不能产出成功结果。机器客户端暂不缓存公钥;不据本地小样本推断容量。\n\n返回的 `tenantId` 必须是 M1 当前令牌中的 canonical 标识;旧 UUID、别名和非法 ULID 即使签名有效也拒绝,客户端不推断或改写映射。\n`authorizationVersion` 与 `serviceVersion` 分别返回,调用方不得忽略主体撤销版本或自行拼接为授权。\n本组合包含 canonical Token 与候选解析实现;完整组合验收另行取得。M2 租约适配、真实 HR/OS 接入、生产凭据注入和长连接关闭仍需独立完成。\n真实 NestJS M1 + 普通角色 PostgreSQL 的 SDK 验收在 `runtime/test/e2e/identity-machine-client.test.ts`;\n它也生成单独的 `reports/machine-revocation-sla.latest.json`,不替代 Employment/Scope 撤权报告。\n\n### 宿主机器鉴权接缝(KI-2)\n\n`parsePlatformMachineTrust` / `createPlatformMachineVerifier` 供 NestJS、Fastify 宿主统一使用。\n仅从固定 issuer map 选择既有机器 SDK,成功结果分别保留 `clientId` 与 `applicationId`,逐次实时 introspection;\n机器声明不会回退旧 JWT 验证。配置、Fact Scope 与租户内应用映射见仓根\n[IdP 与事实通道接缝参考](../../../docs/integration/IdP与事实通道接缝参考-KI-1-KI-3.md)。这些新增导出尚未发布到 Registry。\n","repository":{"type":"git","url":"git@gitea.g-hi.com:luoanwu/enterprise-platform.git"}}
TEXT
download_count
INTEGER NOT NULL (default 0
Update
Cancel