多 key:OAuth 登录签发附加 key 不再轮换,keys 管理端点

This commit is contained in:
host committed 2026-10-26 16:27:42 +08:00
1 parent aa5ad41eba
commit 7b85b4a4fd
7 files changed
+544 -37

No files matched your search

+9 -6
View File
@@ -602,12 +602,14 @@ def map_external_identity_to_local_user_with_key(auth_store, provider,
返回 ``(user_id, created, api_key_plain, rotated)``:
- 新用户:经 ``AuthStore.create_user`` 创建,返回创建时生成的
key,``rotated`` 为 False;
- 已存在用户:经 ``AuthStore.rotate_api_key`` 轮换,返回新 key,
旧 key 即失效,``rotated`` 为 True;
primary key,``rotated`` 为 False;
- 已存在用户:经 ``AuthStore.create_api_key`` 签发一个附加 key
(label 为 ``oauth:<provider>``),旧 key(primary 与之前
的附加 key)全部继续有效,``rotated`` 恒为 False;
调用方须把明文 key 只在回调成功页/响应里展示一次,之后任何
接口都不再返回它;审计由 server 层记(oauth_login 恒记,
轮换时另记 api_key_rotated)。
签发附加 key 时另记 api_key_issued)。``rotated`` 字段只为
向后兼容保留,恒为 False——登录不再轮换任何 key。
"""
_provider_config(provider)
login = identity.get("login") or identity.get("external_id") \
@@ -625,8 +627,9 @@ def map_external_identity_to_local_user_with_key(auth_store, provider,
# 新用户:直接返回创建时生成的 key,不再多轮换一次。
user_id, api_key_plain = auth_store.create_user(username)
return user_id, True, api_key_plain, False
api_key_plain = auth_store.rotate_api_key(row[0])
return row[0], False, api_key_plain, True
_key_id, api_key_plain = auth_store.create_api_key(
row[0], "oauth:%s" % provider)
return row[0], False, api_key_plain, False
def _binding_key(identity):