diff --git a/core/modules/basic_auth/src/Authentication/Provider/BasicAuth.php b/core/modules/basic_auth/src/Authentication/Provider/BasicAuth.php
index eac482c..d7fd67f 100644
--- a/core/modules/basic_auth/src/Authentication/Provider/BasicAuth.php
+++ b/core/modules/basic_auth/src/Authentication/Provider/BasicAuth.php
@@ -68,9 +68,15 @@ public function __construct(ConfigFactoryInterface $config_factory, UserAuthInte
    * {@inheritdoc}
    */
   public function applies(Request $request) {
-    $username = $request->headers->get('PHP_AUTH_USER');
-    $password = $request->headers->get('PHP_AUTH_PW');
-    return isset($username) && isset($password);
+    $www_auth = $request->headers->get('www-authenticate');
+    if (preg_match("/Basic realm=('|\")Drupal('|\")/", $www_auth)) {
+      $username = $request->headers->get('PHP_AUTH_USER');
+      $password = $request->headers->get('PHP_AUTH_PW');
+
+      return isset($username) && isset($password);
+    }
+
+    return FALSE;
   }
 
   /**
