true ]; try { array_push($issues, ...self::_check_endpoint_accessability()); } catch (Exception $e) { array_push($issues, self::_format_issue(sprintf( __('Unexpected application error: %s', AAM_KEY), $e->getMessage() ), 'error')); } if (count($issues) > 0) { $response['issues'] = $issues; } // Determine final status for the check self::_determine_check_status($response); return $response; } /** * Detect empty roles * * @return array * * @access private * @static * @version 6.9.40 */ private static function _check_endpoint_accessability() { $response = []; $visitor = AAM::api()->visitor(); // Check if API route "/" is enabled $api_route_enabled = !$visitor->api_routes()->is_denied('/'); // Additionally check if the same endpoint is restricted with URL Access // service $matched = $visitor->urls()->is_denied(rest_url()); $url_enabled = empty($matched) || $matched['type'] === 'allow'; // Verifying that auto-discover endpoint is disabled for visitors if ($url_enabled && $api_route_enabled) { array_push($response, self::_format_issue( __('Detected open to unauthenticated users RESTful auto-discover endpoint', AAM_KEY), 'warning' )); } return $response; } }