fix(captcha): close human-verification loop end-to-end
Rewrite captcha core around aksrt_captcha_config only, require captcha on login/comment/SMS/phone auth and related gates, wire frontend token collection, and remove dead dual-source security settings plus slider enqueue.
This commit is contained in:
@@ -173,8 +173,12 @@ class AKSRT_Admin_Extension_Controller extends AKSRT_Admin_Controller_Base {
|
||||
$email_gate_enabled = false;
|
||||
}
|
||||
|
||||
$captcha_comment_enabled = !empty($settings['captcha_comment_enabled']);
|
||||
$captcha_download_enabled = !empty($settings['captcha_download_enabled']);
|
||||
$captcha_summary = function_exists('aksrt_get_captcha_status_summary')
|
||||
? aksrt_get_captcha_status_summary()
|
||||
: ['enabled' => false, 'configured' => false, 'scenes' => []];
|
||||
$captcha_comment_enabled = !empty($captcha_summary['scenes']['comment']);
|
||||
$features = class_exists('AKSRT_Settings') ? AKSRT_Settings::get_cms_features() : [];
|
||||
$captcha_download_enabled = !empty($features['download_captcha']) && !empty($captcha_summary['scenes']['download']);
|
||||
|
||||
$risk_switches = [
|
||||
'show_unapproved_comments' => !empty($settings['show_unapproved_comments']),
|
||||
@@ -191,7 +195,8 @@ class AKSRT_Admin_Extension_Controller extends AKSRT_Admin_Controller_Base {
|
||||
'content_audit_configured' => !empty($services['audit']['configured']),
|
||||
'ip_geo_enabled' => !empty($services['ip_geo']['enabled']),
|
||||
'ip_geo_configured' => !empty($services['ip_geo']['configured']),
|
||||
'captcha_enabled' => $captcha_comment_enabled || $captcha_download_enabled,
|
||||
'captcha_enabled' => !empty($captcha_summary['enabled']) && !empty($captcha_summary['configured']),
|
||||
'captcha_summary' => $captcha_summary,
|
||||
'risk_switches' => $risk_switches,
|
||||
'services' => $services,
|
||||
],
|
||||
@@ -452,17 +457,19 @@ class AKSRT_Admin_Extension_Controller extends AKSRT_Admin_Controller_Base {
|
||||
$services['wechat'] = ['enabled' => false, 'provider' => '', 'configured' => false, 'available' => false, 'verified' => false, 'transport' => '', 'missing_fields' => []];
|
||||
}
|
||||
|
||||
// Captcha
|
||||
$settings = AKSRT_Settings::get_all();
|
||||
$captcha_en = class_exists('AKSRT_Captcha') && !empty($settings['captcha_enabled']);
|
||||
// Captcha — 唯一真相源 aksrt_captcha_config
|
||||
$captcha = function_exists('aksrt_get_captcha_status_summary')
|
||||
? aksrt_get_captcha_status_summary()
|
||||
: ['enabled' => false, 'provider' => '', 'configured' => false, 'scenes' => []];
|
||||
$services['captcha'] = [
|
||||
'enabled' => $captcha_en,
|
||||
'provider' => sanitize_key((string) ($settings['captcha_provider'] ?? '')),
|
||||
'configured' => $captcha_en,
|
||||
'available' => $captcha_en,
|
||||
'enabled' => !empty($captcha['enabled']) && !empty($captcha['configured']),
|
||||
'provider' => (string) ($captcha['provider'] ?? ''),
|
||||
'configured' => !empty($captcha['configured']),
|
||||
'available' => !empty($captcha['configured']),
|
||||
'verified' => false,
|
||||
'transport' => 'http_api',
|
||||
'missing_fields' => [],
|
||||
'scenes' => $captcha['scenes'] ?? [],
|
||||
];
|
||||
|
||||
// IP Geo
|
||||
|
||||
@@ -181,6 +181,17 @@ trait AKSRT_Admin_User_Controller_Auth_Phone_Operations {
|
||||
public function auth_send_sms_code(WP_REST_Request $request): WP_REST_Response {
|
||||
$params = $this->get_json_params($request);
|
||||
$phone = sanitize_text_field((string) ($params['phone'] ?? ''));
|
||||
$scene = sanitize_key((string) ($params['scene'] ?? 'register'));
|
||||
if (!array_key_exists($scene, function_exists('aksrt_captcha_scenes') ? aksrt_captcha_scenes() : [])) {
|
||||
$scene = 'register';
|
||||
}
|
||||
|
||||
if (function_exists('aksrt_require_captcha')) {
|
||||
$captcha_result = aksrt_require_captcha($scene, is_array($params) ? $params : []);
|
||||
if ($captcha_result !== true) {
|
||||
return $this->error((string) $captcha_result, 400);
|
||||
}
|
||||
}
|
||||
|
||||
if (!class_exists('AKSRT_SMS')) {
|
||||
return $this->error('短信服务不可用');
|
||||
|
||||
@@ -52,28 +52,8 @@ class AKSRT_Admin_Schema_Extensions_Security {
|
||||
['key' => 'time_format', 'label' => '时间显示格式', 'type' => 'input', 'default' => 'n月j日 H:i'],
|
||||
['key' => 'remove_more_wp_head', 'label' => '移除WP head多余代码', 'type' => 'switch', 'default' => true],
|
||||
]],
|
||||
['key' => 'verification', 'title' => '验证设置', 'fields' => [
|
||||
['key' => 'verification_comment_s', 'label' => '评论需要验证', 'type' => 'switch', 'default' => false],
|
||||
['key' => 'verification_links_s', 'label' => '链接需要验证', 'type' => 'switch', 'default' => true],
|
||||
['key' => 'verification_newposts_s', 'label' => '新文章需要验证', 'type' => 'switch', 'default' => false],
|
||||
['key' => 'verification_bbspost_s', 'label' => '论坛帖子需要验证', 'type' => 'switch', 'default' => false],
|
||||
['key' => 'verification_signin_exclude', 'label' => '登录人机验证排除账号', 'type' => 'input', 'default' => ''],
|
||||
['key' => 'user_verification_type', 'label' => '验证类型', 'type' => 'radio', 'default' => 'slider', 'options' => [
|
||||
['label' => '图形验证码', 'value' => 'image'],
|
||||
['label' => '滑块验证', 'value' => 'slider'],
|
||||
['label' => '腾讯验证码', 'value' => 'tcaptcha'],
|
||||
['label' => '极验验证码', 'value' => 'geetest'],
|
||||
['label' => '关闭验证', 'value' => 'null'],
|
||||
]],
|
||||
]],
|
||||
['key' => 'captcha', 'title' => '验证码设置', 'fields' => [
|
||||
['key' => 'geetest_enabled', 'label' => '极验验证码', 'type' => 'switch', 'default' => false],
|
||||
['key' => 'geetest_id', 'label' => '极验 ID', 'type' => 'input', 'default' => ''],
|
||||
['key' => 'geetest_key', 'label' => '极验 Key', 'type' => 'input', 'default' => ''],
|
||||
['key' => 'tcaptcha_enabled', 'label' => '腾讯云验证码', 'type' => 'switch', 'default' => false],
|
||||
['key' => 'tcaptcha_appid', 'label' => '腾讯云 AppID', 'type' => 'input', 'default' => ''],
|
||||
['key' => 'tcaptcha_secret_id', 'label' => '腾讯云 SecretId', 'type' => 'input', 'default' => ''],
|
||||
['key' => 'tcaptcha_secret_key', 'label' => '腾讯云 SecretKey', 'type' => 'input', 'default' => ''],
|
||||
['key' => 'captcha-note', 'title' => '人机验证', 'fields' => [
|
||||
['key' => 'captcha_redirect_hint', 'label' => '配置入口', 'type' => 'notice', 'alertType' => 'info', 'alertContent' => '人机验证(腾讯云 / 阿里云 / Cloudflare / 极验)请到「功能&权限 → 登录权限」统一配置;本页不再维护验证码字段。'],
|
||||
]],
|
||||
['key' => 'rate-limit', 'title' => '频率限制', 'fields' => [
|
||||
['key' => 'brush_limit_post_enabled', 'label' => '文章发布限制', 'type' => 'switch', 'default' => false],
|
||||
|
||||
@@ -137,7 +137,7 @@ class AKSRT_Admin_Schema_Permissions {
|
||||
['key' => 'download_role_size', 'label' => '角色文件大小限制', 'type' => 'textarea', 'default' => '', 'help' => '格式: role|max_size_mb,每行一条'],
|
||||
]],
|
||||
['key' => 'captcha', 'title' => '安全设置', 'fields' => [
|
||||
['key' => 'download_captcha', 'label' => '下载需要验证码', 'type' => 'switch', 'default' => false],
|
||||
['key' => 'download_captcha_hint', 'label' => '下载验证码', 'type' => 'notice', 'alertType' => 'info', 'alertContent' => '下载验证码门槛在「功能&权限 → 下载权限」页(cms_features.download_captcha)维护;服务商与场景在「登录权限」。'],
|
||||
['key' => 'download_ip_limit', 'label' => 'IP下载限制', 'type' => 'number', 'default' => 0, 'min' => 0, 'help' => '同一IP每小时最大下载次数,0为不限制'],
|
||||
]],
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user