feat(auth): 重构统一认证并支持平级服务无感登录
This commit is contained in:
1 parent
d79def5519
commit
ca312ea751
64 files changed
+3713
-449
No files matched your search
@@ -0,0 +1,31 @@
|
||||
"""
|
||||
backend/app/services/auth/hxops/session_token.py
|
||||
|
||||
用途:为 HXOPS 本地 API 签发包含 Casdoor 稳定身份引用的会话 JWT。
|
||||
依赖:User、AuthIdentity、app.core.auth.jwt 现有签发函数。
|
||||
逻辑:保留现有 HS256 claims 和有效期;只调整调用边界,不改变 Token 契约。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from app.core.auth.jwt import issue_local_access_token
|
||||
from app.models import User
|
||||
from app.services.auth.common import AuthIdentity
|
||||
|
||||
|
||||
def issue_hxops_access_token(user: User, identity: AuthIdentity | None = None) -> str:
|
||||
"""
|
||||
签发 HXOPS API 会话 JWT,保持重构前 claims 完全兼容。
|
||||
|
||||
Args:
|
||||
user: 已映射并检查 active 的 HXOPS 用户。
|
||||
identity: 可选 Casdoor 稳定身份;存在时写入 casdoor_iss/casdoor_sub。
|
||||
|
||||
Returns:
|
||||
由 HXOPS SECRET_KEY 签名的本站 Bearer Token。
|
||||
"""
|
||||
return issue_local_access_token(
|
||||
user,
|
||||
casdoor_issuer=identity.issuer if identity else None,
|
||||
casdoor_subject=identity.subject if identity else None,
|
||||
)
|
||||
Reference in new issue
Block a user