feat: support moi apikey authorization for memoria#31
Open
loveRhythm1990 wants to merge 2 commits intomatrixorigin:0316-beta-launchfrom
Open
feat: support moi apikey authorization for memoria#31loveRhythm1990 wants to merge 2 commits intomatrixorigin:0316-beta-launchfrom
loveRhythm1990 wants to merge 2 commits intomatrixorigin:0316-beta-launchfrom
Conversation
f3771ed to
2d2fc8d
Compare
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.
What type of PR is this?
Which issue(s) this PR fixes
Fixes # https://github.com/matrixorigin/matrixflow/issues/8580
What this PR does / why we need it
新增
--apikey认证模式,支持通过外部 Remote Auth Service 将 API Key 解析为独立的 per-user MatrixOne 数据库连接。核心改动:
dependencies.py:新增AuthContext统一认证上下文,通过X-API-Key/Authorization: Bearer头自动分发到 apikey 或 token 模式remote_auth_service.py:新增 Remote Auth Service 客户端,调用POST /apikey/connection解析 API Key,带 TTL 缓存database.py:新增get_user_session_factory()per-user 引擎缓存(lru_cache(128)),首次连接自动建表config.py:新增remote_auth_service_url、conn_cache_ttl配置项main.py:apikey 模式下跳过自动 governance scheduler,仅支持按需触发middleware.py:Rate limiter 支持从X-API-Key头提取客户端标识cli.py:memoria init --apikey生成对应 mcp.json 配置,与--token互斥mcp_local/server.py:MCP 入口新增--apikey参数AuthContext依赖注入,token 模式完全不受影响新增文件:
docs/apikey-mode.md(使用文档)、docs/design-apikey-mode.md(架构设计文档)、tests/unit/test_apikey_auth.py(25 个测试用例)