casdoor对接企业微信,casdoor端口地址改为8870
This commit is contained in:
1 parent
7eed474125
commit
c21a831796
14 files changed
+375
-28
No files matched your search
@@ -992,6 +992,10 @@ def casdoor_authorize_url():
|
||||
Request:
|
||||
GET /api/user/casdoor/authorize-url
|
||||
|
||||
Optional query:
|
||||
redirect_uri, provider_hint, default_provider=wecom (uses CASDOOR_WECOM_PROVIDER_HINT),
|
||||
silent_signin=1 or CASDOOR_WECOM_SILENT_SIGNIN for silentSignin=1.
|
||||
|
||||
Response 200:
|
||||
{
|
||||
"url": "<authorization endpoint with state>",
|
||||
@@ -1015,6 +1019,14 @@ def casdoor_authorize_url():
|
||||
scope = current_app.config.get('CASDOOR_SCOPE') or 'openid profile email'
|
||||
if not client_id or not redirect_uri:
|
||||
return jsonify({'error': 'Casdoor client config is incomplete'}), 500
|
||||
default_provider = (_clean_str(request.args.get('default_provider')) or '').lower()
|
||||
provider_hint = _clean_str(request.args.get('provider_hint'))
|
||||
if not provider_hint and default_provider == 'wecom':
|
||||
provider_hint = current_app.config.get('CASDOOR_WECOM_PROVIDER_HINT') or ''
|
||||
silent_raw = (_clean_str(request.args.get('silent_signin')) or '').lower()
|
||||
silent_signin = silent_raw in ('1', 'true', 'yes')
|
||||
if not silent_signin and default_provider == 'wecom':
|
||||
silent_signin = bool(current_app.config.get('CASDOOR_WECOM_SILENT_SIGNIN'))
|
||||
state = _issue_casdoor_state(redirect_uri)
|
||||
url = (
|
||||
f"{authorize_endpoint}?client_id={quote(client_id, safe='')}"
|
||||
@@ -1023,6 +1035,10 @@ def casdoor_authorize_url():
|
||||
f"&scope={quote(scope, safe='')}"
|
||||
f"&state={quote(state, safe='')}"
|
||||
)
|
||||
if provider_hint:
|
||||
url += f"&provider_hint={quote(provider_hint, safe='')}"
|
||||
if silent_signin:
|
||||
url += '&silentSignin=1'
|
||||
return jsonify({'url': url, 'state': state, 'redirect_uri': redirect_uri})
|
||||
except Exception as e:
|
||||
return jsonify({'error': f'Failed to build Casdoor authorize url: {str(e)}'}), 500
|
||||
|
||||
Reference in new issue
Block a user