Merged
Conversation
|
|
MaojiaSheng
approved these changes
Feb 24, 2026
MaojiaSheng
approved these changes
Feb 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
实现多租户 Phase 1,建立身份、认证、授权的基础框架。包括两层 API Key 体系(Root/User,纯随机 token 无前缀)、三层 RBAC 角色模型(ROOT/ADMIN/USER)、认证中间件重写、Admin API 以及所有 Router 的依赖注入迁移。
Related Issue
Ref #158
Type of Change
Changes Made
核心模块
openviking/server/identity.py:定义 Role 枚举(ROOT/ADMIN/USER)、ResolvedIdentity、RequestContext 类型openviking/server/api_keys.py:API Key Manager,支持 Root/User 两种纯随机 token 的生成、解析与管理,per-account 持久化到/{account_id}/_system/users.jsonopenviking/server/auth.py:新增 resolve_identity()(HMAC 比对 root key -> 查 user key 索引)、get_request_context()、require_role() 角色守卫openviking/server/config.py:api_key -> root_api_key,为 None 时进入 dev 模式openviking/server/app.py:按 root_api_key 是否配置分派初始化逻辑Admin API
openviking/server/routers/admin.py:工作区 CRUD、用户注册/移除/角色变更、Key 生成/重置等管理端点Router 迁移
Depends(verify_api_key)迁移到Depends(get_request_context)客户端 SDK
文档
docs/en/api/08-admin.md,docs/zh/api/08-admin.md)examples/multi_tenant/)测试
tests/server/test_admin_api.py:Admin API 集成测试tests/server/test_api_key_manager.py:API Key Manager 单元测试tests/server/test_identity.py:身份模块单元测试tests/server/test_auth.py:认证中间件测试适配Testing
Checklist
Additional Notes