1313use Magento \Framework \HTTP \Client \CurlFactory ;
1414use Magento \Framework \Serialize \Serializer \Json ;
1515use Psr \Log \LoggerInterface ;
16+ use Magento \Framework \HTTP \PhpEnvironment \RemoteAddress ;
1617
1718class Validate implements ValidateInterface
1819{
@@ -43,23 +44,31 @@ class Validate implements ValidateInterface
4344 private $ serializer ;
4445
4546 /**
46- * Validate constructor.
47+ * @var
48+ */
49+ private $ remoteAddress ;
50+
51+ /**
52+ * Validate Constructor
4753 *
4854 * @param LoggerInterface $logger
4955 * @param Config $config
5056 * @param CurlFactory $curlFactory
5157 * @param Json $serializer
58+ * @param RemoteAddress $remoteAddress
5259 */
5360 public function __construct (
5461 LoggerInterface $ logger ,
5562 Config $ config ,
5663 CurlFactory $ curlFactory ,
57- Json $ serializer
64+ Json $ serializer ,
65+ RemoteAddress $ remoteAddress
5866 ) {
5967 $ this ->logger = $ logger ;
6068 $ this ->config = $ config ;
6169 $ this ->curlFactory = $ curlFactory ;
6270 $ this ->serializer = $ serializer ;
71+ $ this ->remoteAddress = $ remoteAddress ;
6372 }
6473
6574 /**
@@ -71,6 +80,12 @@ public function __construct(
7180 */
7281 public function validate (string $ friendlyCaptchaSolution ): bool
7382 {
83+ $ ips = $ this ->config ->getTrustedIps ();
84+ $ clientIp = $ this ->remoteAddress ->getRemoteAddress ();
85+ if ($ ips !== [] && in_array ((string )$ clientIp , $ ips , true )) {
86+ return true ;
87+ }
88+
7489 $ parameters = [
7590 self ::PARAMETER_SOLUTION => $ friendlyCaptchaSolution ,
7691 self ::PARAMETER_SECRET => $ this ->config ->getApikey (),
0 commit comments