修改casdoor issuer为域名地址,同时默认登录方式为casdoor
This commit is contained in:
1 parent
f851e5d3ff
commit
8c8a65d838
6 files changed
+35
-5
No files matched your search
@@ -18,7 +18,7 @@ CASDOOR_SCOPE=openid profile email
|
|||||||
# Casdoor Providers → wecom(Name=wecom,与 prod 共用同一 Provider 即可)
|
# Casdoor Providers → wecom(Name=wecom,与 prod 共用同一 Provider 即可)
|
||||||
CASDOOR_WECOM_PROVIDER_HINT=wecom
|
CASDOOR_WECOM_PROVIDER_HINT=wecom
|
||||||
|
|
||||||
AUTH_JWT_ISSUER=http://192.168.100.230:8870
|
AUTH_JWT_ISSUER=http://ai.well-trust.com:8870
|
||||||
AUTH_JWT_AUDIENCE=<hxops-dev-client-id>
|
AUTH_JWT_AUDIENCE=<hxops-dev-client-id>
|
||||||
AUTH_JWT_JWKS_URL=http://192.168.100.230:8870/.well-known/jwks
|
AUTH_JWT_JWKS_URL=http://192.168.100.230:8870/.well-known/jwks
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ CASDOOR_SCOPE=openid profile email
|
|||||||
# Casdoor Providers → wecom:Name 字段(截图即为 wecom);Organization=organization_HX,Sub type=Internal,Scope=snsapi_userinfo
|
# Casdoor Providers → wecom:Name 字段(截图即为 wecom);Organization=organization_HX,Sub type=Internal,Scope=snsapi_userinfo
|
||||||
CASDOOR_WECOM_PROVIDER_HINT=wecom
|
CASDOOR_WECOM_PROVIDER_HINT=wecom
|
||||||
|
|
||||||
AUTH_JWT_ISSUER=http://192.168.100.230:8870
|
AUTH_JWT_ISSUER=http://ai.well-trust.com:8870
|
||||||
AUTH_JWT_AUDIENCE=758be5fcba2df784fdb4
|
AUTH_JWT_AUDIENCE=758be5fcba2df784fdb4
|
||||||
AUTH_JWT_JWKS_URL=http://192.168.100.230:8870/.well-known/jwks
|
AUTH_JWT_JWKS_URL=http://192.168.100.230:8870/.well-known/jwks
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ CASDOOR_SCOPE=openid profile email
|
|||||||
# Casdoor Providers → wecom(Name=wecom)
|
# Casdoor Providers → wecom(Name=wecom)
|
||||||
CASDOOR_WECOM_PROVIDER_HINT=wecom
|
CASDOOR_WECOM_PROVIDER_HINT=wecom
|
||||||
|
|
||||||
AUTH_JWT_ISSUER=http://192.168.100.230:8870
|
AUTH_JWT_ISSUER=http://ai.well-trust.com:8870
|
||||||
AUTH_JWT_AUDIENCE=<hxops-test-client-id>
|
AUTH_JWT_AUDIENCE=<hxops-test-client-id>
|
||||||
AUTH_JWT_JWKS_URL=http://192.168.100.230:8870/.well-known/jwks
|
AUTH_JWT_JWKS_URL=http://192.168.100.230:8870/.well-known/jwks
|
||||||
|
|
||||||
|
|||||||
+3
-1
@@ -6,9 +6,11 @@ INTEGRATION_API_KEY=I76mSQZQEPYU6TubMhjh-xLsCgWC0gSIg5MncJFHFCvqvVlg-gZ_BvwO_UEL
|
|||||||
AUTH_JWT_REQUIRED=true
|
AUTH_JWT_REQUIRED=true
|
||||||
|
|
||||||
AUTH_LOGIN_MODE=casdoor
|
AUTH_LOGIN_MODE=casdoor
|
||||||
|
# 如果需要用户密码登录,修改该值为password
|
||||||
|
# AUTH_LOGIN_MODE=password
|
||||||
|
|
||||||
# Casdoor JWT 验签三件套
|
# Casdoor JWT 验签三件套
|
||||||
AUTH_JWT_ISSUER=http://192.168.100.230:8870
|
AUTH_JWT_ISSUER=http://ai.well-trust.com:8870
|
||||||
AUTH_JWT_AUDIENCE=758be5fcba2df784fdb4
|
AUTH_JWT_AUDIENCE=758be5fcba2df784fdb4
|
||||||
AUTH_JWT_JWKS_URL=http://192.168.100.230:8870/.well-known/jwks
|
AUTH_JWT_JWKS_URL=http://192.168.100.230:8870/.well-known/jwks
|
||||||
|
|
||||||
|
|||||||
@@ -136,6 +136,24 @@ def _decode_jwt(token: str) -> dict:
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def _extract_unverified_claims(token: str) -> dict:
|
||||||
|
"""Best-effort decode without signature verification for troubleshooting logs."""
|
||||||
|
try:
|
||||||
|
return jwt.decode(
|
||||||
|
token,
|
||||||
|
options={
|
||||||
|
'verify_signature': False,
|
||||||
|
'verify_exp': False,
|
||||||
|
'verify_iat': False,
|
||||||
|
'verify_nbf': False,
|
||||||
|
'verify_aud': False,
|
||||||
|
'verify_iss': False,
|
||||||
|
},
|
||||||
|
) or {}
|
||||||
|
except Exception:
|
||||||
|
return {}
|
||||||
|
|
||||||
|
|
||||||
def _resolve_user_from_claims(claims: dict) -> Optional[User]:
|
def _resolve_user_from_claims(claims: dict) -> Optional[User]:
|
||||||
# Resolution order keeps compatibility with different token claim conventions.
|
# Resolution order keeps compatibility with different token claim conventions.
|
||||||
user_id = claims.get('user_id') or claims.get('id')
|
user_id = claims.get('user_id') or claims.get('id')
|
||||||
@@ -195,6 +213,16 @@ def get_current_user() -> Optional[User]:
|
|||||||
)
|
)
|
||||||
except Exception:
|
except Exception:
|
||||||
# Any decode/lookup failure should behave as unauthenticated.
|
# Any decode/lookup failure should behave as unauthenticated.
|
||||||
|
unverified = _extract_unverified_claims(token)
|
||||||
|
expected_issuer = (current_app.config.get('AUTH_JWT_ISSUER') or '').strip()
|
||||||
|
expected_audience = (current_app.config.get('AUTH_JWT_AUDIENCE') or '').strip()
|
||||||
|
current_app.logger.error(
|
||||||
|
'[auth_jwt] decode context token_iss=%s token_aud=%s expected_iss=%s expected_aud=%s',
|
||||||
|
unverified.get('iss'),
|
||||||
|
unverified.get('aud'),
|
||||||
|
expected_issuer,
|
||||||
|
expected_audience,
|
||||||
|
)
|
||||||
current_app.logger.exception('[auth_jwt] decode failed token=%s path=%s', _token_brief(token), request.path)
|
current_app.logger.exception('[auth_jwt] decode failed token=%s path=%s', _token_brief(token), request.path)
|
||||||
user = None
|
user = None
|
||||||
claims = None
|
claims = None
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ export const config = {
|
|||||||
// Login mode switch:
|
// Login mode switch:
|
||||||
// - 'casdoor': submit username/password to backend Casdoor password-login API.
|
// - 'casdoor': submit username/password to backend Casdoor password-login API.
|
||||||
// - 'password': submit to legacy local /api/user/login.
|
// - 'password': submit to legacy local /api/user/login.
|
||||||
loginMode: 'password',
|
loginMode: 'casdoor',
|
||||||
casdoor: {
|
casdoor: {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
authorizeApi: '/api/user/casdoor/authorize-url',
|
authorizeApi: '/api/user/casdoor/authorize-url',
|
||||||
|
|||||||
Reference in new issue
Block a user