diff --git a/core/authorize.php b/core/authorize.php
index f938f39..f2017c5 100644
--- a/core/authorize.php
+++ b/core/authorize.php
@@ -22,6 +22,7 @@
 
 use Drupal\Core\Site\Settings;
 use Drupal\Core\Page\DefaultHtmlPageRenderer;
+use Symfony\Component\HttpFoundation\Request;
 
 // Change the directory to the Drupal root.
 chdir('..');
@@ -46,8 +47,9 @@
  * @return bool
  *   TRUE if the current user can run authorize.php, and FALSE if not.
  */
-function authorize_access_allowed() {
-  \Drupal::service('session_manager')->initialize();
+function authorize_access_allowed(Request $request) {
+  $account = \Drupal::service('authentication')->authenticate($request);
+  \Drupal::service('current_user')->setAccount($account);
   return Settings::get('allow_authorize_operations', TRUE) && user_access('administer software updates');
 }
 
@@ -77,7 +79,7 @@ function authorize_access_allowed() {
 $output = '';
 $show_messages = TRUE;
 
-if (authorize_access_allowed()) {
+if (authorize_access_allowed($request)) {
   // Load both the Form API and Batch API.
   require_once __DIR__ . '/includes/form.inc';
   require_once __DIR__ . '/includes/batch.inc';
diff --git a/core/core.services.yml b/core/core.services.yml
index f715064..a14e7aa 100644
--- a/core/core.services.yml
+++ b/core/core.services.yml
@@ -471,11 +471,6 @@ services:
     tags:
       - { name: route_enhancer }
       - { name: event_subscriber }
-  route_enhancer.authentication:
-    class: Drupal\Core\Routing\Enhancer\AuthenticationEnhancer
-    tags:
-      - { name: route_enhancer, priority: 1000 }
-    arguments: ['@authentication', '@current_user']
   route_enhancer.entity:
     class: Drupal\Core\Entity\Enhancer\EntityRouteEnhancer
     arguments: ['@controller_resolver', '@entity.manager', '@form_builder']
@@ -782,10 +777,11 @@ services:
     class: Drupal\Core\EventSubscriber\AuthenticationSubscriber
     tags:
       - { name: event_subscriber }
-    arguments: ['@authentication']
+    arguments: ['@authentication', '@current_user']
   current_user:
     class: Drupal\Core\Session\AccountProxy
-    arguments: ['@authentication', '@request']
+    tags:
+      - { name: persist }
   session_manager:
     class: Drupal\Core\Session\SessionManager
     arguments: ['@request_stack', '@database', '@session_manager.metadata_bag', '@settings']
diff --git a/core/lib/Drupal/Core/Authentication/AuthenticationManager.php b/core/lib/Drupal/Core/Authentication/AuthenticationManager.php
index 1a7ca6e..df35ce8 100644
--- a/core/lib/Drupal/Core/Authentication/AuthenticationManager.php
+++ b/core/lib/Drupal/Core/Authentication/AuthenticationManager.php
@@ -88,8 +88,18 @@ public function authenticate(Request $request) {
 
     $account = NULL;
 
-    // Iterate the availlable providers.
-    foreach ($this->getSortedProviders() as $provider_id => $provider) {
+    $auth_providers = $this->getSortedProviders();
+
+    if ($request->attributes->has(RouteObjectInterface::ROUTE_OBJECT)) {
+      $route = $request->attributes->get(RouteObjectInterface::ROUTE_OBJECT);
+      if ($route->hasOption('_auth')) {
+        $allowed_providers = array_flip($route->getOption('_auth'));
+        $auth_providers = array_intersect_key($auth_providers, $allowed_providers);
+      }
+    }
+
+    // Iterate the allowed providers.
+    foreach ($auth_providers as $provider_id => $provider) {
       if ($provider->applies($request)) {
         // Try to authenticate with this provider, skipping all others.
         $account = $provider->authenticate($request);
diff --git a/core/lib/Drupal/Core/EventSubscriber/AuthenticationSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/AuthenticationSubscriber.php
index 87a3cfe..8e7e52c 100644
--- a/core/lib/Drupal/Core/EventSubscriber/AuthenticationSubscriber.php
+++ b/core/lib/Drupal/Core/EventSubscriber/AuthenticationSubscriber.php
@@ -8,8 +8,10 @@
 namespace Drupal\Core\EventSubscriber;
 
 use Drupal\Core\Authentication\AuthenticationProviderInterface;
+use Drupal\Core\Session\AccountProxyInterface;
 use Symfony\Component\HttpKernel\HttpKernelInterface;
 use Symfony\Component\HttpKernel\KernelEvents;
+use Symfony\Component\HttpKernel\Event\GetResponseEvent;
 use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
 use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
 use Symfony\Component\EventDispatcher\EventSubscriberInterface;
@@ -29,13 +31,35 @@ class AuthenticationSubscriber implements EventSubscriberInterface {
   protected $authenticationProvider;
 
   /**
+   * Current user proxy.
+   *
+   * @var \Drupal\Core\Session\AccountProxyInterface
+   */
+  protected $currentUser;
+
+  /**
    * Keep authentication manager as private variable.
    *
    * @param AuthenticationProviderInterface $authentication_manager
    *   The authentication manager.
+   * @param \Drupal\Core\Session\AccountProxyInterface $current_user
+   *   The current user proxy.
    */
-  public function __construct(AuthenticationProviderInterface $authentication_provider) {
+  public function __construct(AuthenticationProviderInterface $authentication_provider, AccountProxyInterface $current_user) {
     $this->authenticationProvider = $authentication_provider;
+    $this->currentUser = $current_user;
+  }
+
+  /**
+   * Authenticates user on request.
+   *
+   * @see \Drupal\Core\Authentication\AuthenticationProviderInterface::authenticate()
+   */
+  public function onKernelRequestAuthenticate(GetResponseEvent $event) {
+    if ($event->getRequestType() == HttpKernelInterface::MASTER_REQUEST) {
+      $request = $event->getRequest();
+      $this->currentUser->setAccount($this->authenticationProvider->authenticate($request));
+    }
   }
 
   /**
@@ -63,15 +87,13 @@ public function onException(GetResponseForExceptionEvent $event) {
 
   /**
    * {@inheritdoc}
-   *
-   * The priority for request must be higher than the highest event subscriber
-   * accessing the current user.
-   * The priority for the response must be as low as possible allowing e.g the
-   * Cookie provider to send all relevant session data to the user.
    */
   public static function getSubscribedEvents() {
+    // Authentication needs to be performed before the access check.
+    $events[KernelEvents::REQUEST][] = array('onKernelRequestAuthenticate', 31);
     $events[KernelEvents::RESPONSE][] = array('onRespond', 0);
     $events[KernelEvents::EXCEPTION][] = array('onException', 0);
+
     return $events;
   }
 }
diff --git a/core/lib/Drupal/Core/Routing/Enhancer/AuthenticationEnhancer.php b/core/lib/Drupal/Core/Routing/Enhancer/AuthenticationEnhancer.php
deleted file mode 100644
index 0436b44..0000000
--- a/core/lib/Drupal/Core/Routing/Enhancer/AuthenticationEnhancer.php
+++ /dev/null
@@ -1,78 +0,0 @@
-<?php
-
-/**
- * @file
- * Contains \Drupal\Core\Routing\Enhancer\AuthenticationEnhancer.
- */
-
-namespace Drupal\Core\Routing\Enhancer;
-
-use Drupal\Core\Authentication\AuthenticationManagerInterface;
-use Drupal\Core\Session\AccountProxyInterface;
-use Drupal\Core\Session\AnonymousUserSession;
-use Symfony\Cmf\Component\Routing\Enhancer\RouteEnhancerInterface;
-use Symfony\Component\HttpFoundation\Request;
-use Symfony\Cmf\Component\Routing\RouteObjectInterface;
-
-/**
- * Authentication cleanup for incoming routes.
- *
- * The authentication system happens before routing, so all authentication
- * providers will attempt to authorize a user. However, not all routes allow
- * all authentication mechanisms. Instead, we check if the used provider is
- * valid for the matched route and if not, force the user to anonymous.
- */
-class AuthenticationEnhancer implements RouteEnhancerInterface {
-
-  /**
-   * The authentication manager.
-   *
-   * @var \Drupal\Core\Authentication\AuthenticationManager
-   */
-  protected $manager;
-
-  /**
-   * The current user service.
-   *
-   * @var \Drupal\Core\Session\AccountProxyInterface
-   */
-  protected $currentUser;
-
-  /**
-   * Constructs a AuthenticationEnhancer object.
-   *
-   * @param \Drupal\Core\Authentication\AuthenticationManagerInterface $manager
-   *   The authentication manager.
-   * @param \Drupal\Core\Session\AccountProxyInterface $current_user
-   *   The current user service.
-   */
-  function __construct(AuthenticationManagerInterface $manager, AccountProxyInterface $current_user) {
-    $this->manager = $manager;
-    $this->currentUser = $current_user;
-  }
-
-  /**
-   * {@inheritdoc}
-   */
-  public function enhance(array $defaults, Request $request) {
-    $auth_provider_triggered = $request->attributes->get('_authentication_provider');
-    if (!empty($auth_provider_triggered)) {
-      $route = isset($defaults[RouteObjectInterface::ROUTE_OBJECT]) ? $defaults[RouteObjectInterface::ROUTE_OBJECT] : NULL;
-
-      $auth_providers = ($route && $route->getOption('_auth')) ? $route->getOption('_auth') : array($this->manager->defaultProviderId());
-      // If the request was authenticated with a non-permitted provider,
-      // force the user back to anonymous.
-      if (!in_array($auth_provider_triggered, $auth_providers)) {
-        $anonymous_user = new AnonymousUserSession();
-
-        $this->currentUser->setAccount($anonymous_user);
-
-        // The global $user object is included for backward compatibility only
-        // and should be considered deprecated.
-        // @todo Remove this line once global $user is no longer used.
-        $GLOBALS['user'] = $anonymous_user;
-      }
-    }
-    return $defaults;
-  }
-}
diff --git a/core/lib/Drupal/Core/Session/AccountProxy.php b/core/lib/Drupal/Core/Session/AccountProxy.php
index 9f00218..990bd47 100644
--- a/core/lib/Drupal/Core/Session/AccountProxy.php
+++ b/core/lib/Drupal/Core/Session/AccountProxy.php
@@ -7,9 +7,6 @@
 
 namespace Drupal\Core\Session;
 
-use Drupal\Core\Authentication\AuthenticationManagerInterface;
-use Symfony\Component\HttpFoundation\Request;
-
 /**
  * A proxied implementation of AccountInterface.
  *
@@ -24,20 +21,6 @@
 class AccountProxy implements AccountProxyInterface {
 
   /**
-   * The current request.
-   *
-   * @var \Symfony\Component\HttpFoundation\Request
-   */
-  protected $request;
-
-  /**
-   * The authentication manager.
-   *
-   * @var \Drupal\Core\Authentication\AuthenticationManagerInterface
-   */
-  protected $authenticationManager;
-
-  /**
    * The instantiated account.
    *
    * @var \Drupal\Core\Session\AccountInterface
@@ -46,15 +29,9 @@ class AccountProxy implements AccountProxyInterface {
 
   /**
    * Constructs a new AccountProxy.
-   *
-   * @param \Drupal\Core\Authentication\AuthenticationManagerInterface $authentication_manager
-   *   The authentication manager.
-   * @param \Symfony\Component\HttpFoundation\Request $request
-   *   The request object used for authenticating.
    */
-  public function __construct(AuthenticationManagerInterface $authentication_manager, Request $request) {
-    $this->authenticationManager = $authentication_manager;
-    $this->request = $request;
+  public function __construct() {
+    $this->account = new AnonymousUserSession();
   }
 
   /**
@@ -73,9 +50,6 @@ public function setAccount(AccountInterface $account) {
    * {@inheritdoc}
    */
   public function getAccount() {
-    if (!isset($this->account)) {
-      $this->setAccount($this->authenticationManager->authenticate($this->request));
-    }
     return $this->account;
   }
 
@@ -185,4 +159,3 @@ public function getLastAccessedTime() {
   }
 
 }
-
diff --git a/core/modules/basic_auth/src/Authentication/Provider/BasicAuth.php b/core/modules/basic_auth/src/Authentication/Provider/BasicAuth.php
index 4545c19..e021f76 100644
--- a/core/modules/basic_auth/src/Authentication/Provider/BasicAuth.php
+++ b/core/modules/basic_auth/src/Authentication/Provider/BasicAuth.php
@@ -17,6 +17,8 @@
 use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
 use Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException;
 use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
+use Symfony\Cmf\Component\Routing\RouteObjectInterface;
+
 
 /**
  * HTTP Basic authentication provider.
@@ -74,9 +76,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);
+    // Only allow basic auth when it was specified explicitely on the route.
+    if ($request->attributes->has(RouteObjectInterface::ROUTE_OBJECT)) {
+      $route = $request->attributes->get(RouteObjectInterface::ROUTE_OBJECT);
+      if ($route->hasOption('_auth') && in_array('basic_auth', $route->getOption('_auth'))) {
+        $username = $request->headers->get('PHP_AUTH_USER');
+        $password = $request->headers->get('PHP_AUTH_PW');
+        return isset($username) && isset($password);
+      }
+    }
   }
 
   /**
diff --git a/core/update.php b/core/update.php
index b6accf3..e812d3f 100644
--- a/core/update.php
+++ b/core/update.php
@@ -248,8 +248,9 @@ function update_access_denied_page() {
  * @return
  *   TRUE if the current user should be granted access, or FALSE otherwise.
  */
-function update_access_allowed() {
-  $user = \Drupal::currentUser();
+function update_access_allowed(Request $request) {
+  $user = \Drupal::service('authentication')->authenticate($request);
+  \Drupal::service('current_user')->setAccount($user);
 
   // Allow the global variable in settings.php to override the access check.
   if (Settings::get('update_free_access')) {
@@ -361,7 +362,7 @@ function update_task_list($active = NULL) {
 // Only allow the requirements check to proceed if the current user has access
 // to run updates (since it may expose sensitive information about the site's
 // configuration).
-if (is_null($op) && update_access_allowed()) {
+if (is_null($op) && update_access_allowed($request)) {
   require_once __DIR__ . '/includes/install.inc';
   require_once DRUPAL_ROOT . '/core/modules/system/system.install';
 
@@ -388,7 +389,7 @@ function update_task_list($active = NULL) {
 $regions = array();
 
 // Only proceed with updates if the user is allowed to run them.
-if (update_access_allowed()) {
+if (update_access_allowed($request)) {
 
   include_once __DIR__ . '/includes/install.inc';
   include_once __DIR__ . '/includes/batch.inc';
