fix(auth): 重构登录认证,并支持跳转到关联服务如图纸标注
This commit is contained in:
1 parent
ce1fd59f61
commit
affe139bf9
51 files changed
+1939
-132
No files matched your search
@@ -24,6 +24,17 @@ def _claim_text(claims: Mapping[str, Any], *keys: str) -> str | None:
|
||||
return None
|
||||
|
||||
|
||||
def _claim_or_property_text(claims: Mapping[str, Any], *keys: str) -> str | None:
|
||||
"""优先读取顶层 claim,再兼容 Casdoor properties 中同名的用户自定义属性。"""
|
||||
value = _claim_text(claims, *keys)
|
||||
if value:
|
||||
return value
|
||||
properties = claims.get('properties')
|
||||
if isinstance(properties, Mapping):
|
||||
return _claim_text(properties, *keys)
|
||||
return None
|
||||
|
||||
|
||||
def identity_from_claims(
|
||||
claims: Mapping[str, Any],
|
||||
*,
|
||||
@@ -53,7 +64,7 @@ def identity_from_claims(
|
||||
display_name=_claim_text(claims, 'display_name', 'displayName', 'real_name', 'realName', 'name'),
|
||||
email=_claim_text(claims, 'email'),
|
||||
phone_number=_claim_text(claims, 'phone_number', 'phone'),
|
||||
employee_id=_claim_text(claims, 'employee_id', 'employeeId'),
|
||||
employee_id=_claim_or_property_text(claims, 'employee_id', 'employeeId'),
|
||||
department=_claim_text(claims, 'department', 'affiliation'),
|
||||
)
|
||||
return require_stable_identity(identity)
|
||||
Reference in new issue
Block a user