diff --git a/rest_api_authentication.routing.yml b/rest_api_authentication.routing.yml index a5c861e4b7f8b213294d9dfb035534379ae32a78..d9e4ae60f068e661c073af3c3f0044ee09e12e36 100644 --- a/rest_api_authentication.routing.yml +++ b/rest_api_authentication.routing.yml @@ -11,7 +11,7 @@ rest_api_authentication.request_api_support: path: /admin/config/people/rest_api_authentication/requestSupport defaults: _title: 'miniOrange API Authentication Request Support' - _controller: '\Drupal\rest_api_authentication\Form\rest_api_authenticationController::openSupportRequestForm' + _controller: '\Drupal\rest_api_authentication\Controller\rest_api_authenticationController::openSupportRequestForm' requirements: _permission: 'administer site configuration' diff --git a/rest_api_authentication.services.yml b/rest_api_authentication.services.yml index e91ec768a74b6816f061593049dec7e6de99ddf1..062866a3e93dafac5e39a44c54a46b7c432a7247 100644 --- a/rest_api_authentication.services.yml +++ b/rest_api_authentication.services.yml @@ -9,3 +9,7 @@ services: public: false tags: - { name: page_cache_request_policy } + rest_api_authentication.route_subscriber: + class: Drupal\rest_api_authentication\Routing\RouteSubscriber + tags: + - { name: event_subscriber } diff --git a/src/Authentication/Provider/restAPI.php b/src/Authentication/Provider/restAPI.php index 825ea57b852d42bf677eaa5f182f54e244ca63a7..a04dafc43dfa935446eb013dbf048c540ec07fa5 100644 --- a/src/Authentication/Provider/restAPI.php +++ b/src/Authentication/Provider/restAPI.php @@ -69,6 +69,9 @@ class restAPI implements AuthenticationProviderInterface { $api_error = array(); + if ($request->getPathInfo() == "/user/login") { + return null; + } $authentication_method = \Drupal::config('rest_api_authentication.settings')->get('authentication_method'); switch ($authentication_method) { case 0: diff --git a/src/Routing/RouteSubscriber.php b/src/Routing/RouteSubscriber.php new file mode 100644 index 0000000000000000000000000000000000000000..1a79fbb825bb001cc6f5776edca242187eacab03 --- /dev/null +++ b/src/Routing/RouteSubscriber.php @@ -0,0 +1,34 @@ +<?php + +namespace Drupal\rest_api_authentication\Routing; + +use Drupal\Core\Routing\RouteSubscriberBase; +use Symfony\Component\Routing\Route; +use Symfony\Component\Routing\RouteCollection; + +/** + * Listens to the dynamic route events. + */ +class RouteSubscriber extends RouteSubscriberBase { + /** + * {@inheritdoc} + */ + protected function alterRoutes(RouteCollection $collection) { + $route_login = $collection->get('user.login.http'); + $route_login->addOptions([ + '_auth' => [ + 'rest_api_authentication' + ], + ]); + } + + /** + * @param Route $route + * + * @return false|true + */ + private function restLoginRount(Route $route) { + $path = $route->getPath(); + return strpos($path,'/user/login?_format='); + } +}