From a9e874ba88ebdc07848d8d17897e81b0270499b1 Mon Sep 17 00:00:00 2001 From: Yemoko Date: Mon, 20 Aug 2018 09:44:52 +0000 Subject: [PATCH 1/4] OPENEUROPA-1159: Rename Auth to Authentification, rename files, update classes etc. --- README.md | 22 +++++++++---------- composer.json | 8 +++---- oe_auth.info.yml | 5 ----- oe_auth.services.yml | 21 ------------------ oe_authentication.info.yml | 5 +++++ oe_authentication.services.yml | 21 ++++++++++++++++++ runner.yml.dist | 4 ++-- services.yml.dist | 2 +- .../{OeAuth.php => OeAuthentication.php} | 12 +++++----- ...ler.php => OeAuthenticationController.php} | 12 +++++----- ...hp => OeAuthenticationServiceProvider.php} | 6 ++--- src/Routing/RouteSubscriber.php | 6 ++--- src/UserProvider.php | 6 ++--- tests/features/login.feature | 6 ++--- 14 files changed, 68 insertions(+), 68 deletions(-) delete mode 100644 oe_auth.info.yml delete mode 100644 oe_auth.services.yml create mode 100644 oe_authentication.info.yml create mode 100644 oe_authentication.services.yml rename src/Authentication/Provider/{OeAuth.php => OeAuthentication.php} (77%) rename src/Controller/{OeAuthController.php => OeAuthenticationController.php} (89%) rename src/{OeAuthServiceProvider.php => OeAuthenticationServiceProvider.php} (72%) diff --git a/README.md b/README.md index b3eed0be..86f39cac 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ -# OpenEuropa Auth +# OpenEuropa Authentication -[![Build Status](https://drone.fpfis.eu/api/badges/openeuropa/oe_auth/status.svg?branch=master)](https://drone.fpfis.eu/openeuropa/oe_auth) +[![Build Status](https://drone.fpfis.eu/api/badges/openeuropa/oe_authentication/status.svg?branch=master)](https://drone.fpfis.eu/openeuropa/oe_authentication) -The OpenEuropa Auth module allows to authenticate against the European Commission login service. +The OpenEuropa Authentication module allows to authenticate against the European Commission login service. **Table of contents:** @@ -15,10 +15,10 @@ The OpenEuropa Auth module allows to authenticate against the European Commissio ## Installation -The recommended way of installing the OpenEuropa Auth module is via a [Composer][2]. +The recommended way of installing the OpenEuropa Authentication module is via a [Composer][2]. ```bash -composer require openeuropa/oe_auth +composer require openeuropa/oe_authentication ``` Before being able to use the module, you will need to specify the ECAS service base URL @@ -26,7 +26,7 @@ in your Drupal installation's `./sites/default/default.services.yml` file as sho ``` parameters: - oe_auth.pcas.base_url: http://my-ecas-service.com + oe_authentication.pcas.base_url: http://my-ecas-service.com ``` For more information about how to override service parameters in Drupal 8 @@ -37,12 +37,12 @@ check the [related documentation page](https://www.drupal.org/docs/8/api/service In order to enable the module in your project run: ``` -$ ./vendor/bin/drush en oe_auth +$ ./vendor/bin/drush en oe_authentication ``` ## Development -The OpenEuropa Auth project contains all the necessary code and tools for an effective development process, +The OpenEuropa Authentication project contains all the necessary code and tools for an effective development process, such as: - All PHP development dependencies (Drupal core included) are required by [composer.json](composer.json) @@ -72,7 +72,7 @@ $ ./vendor/bin/run drupal:site-setup This will: -- Symlink the theme in `./build/modules/custom/oe_auth` so that it's available for the test site +- Symlink the theme in `./build/modules/custom/oe_authentication` so that it's available for the test site - Setup Drush and Drupal's settings using values from `./runner.yml.dist` - Setup PHPUnit and Behat configuration files using values from `./runner.yml.dist` @@ -85,7 +85,7 @@ $ ./vendor/bin/run drupal:site-install This will: - Install the test site -- Enable the OpenEuropa Auth module +- Enable the OpenEuropa Authentication module Then setup the mock servers dependencies by running: ``` @@ -114,7 +114,7 @@ $ docker-compose exec web composer install $ docker-compose exec web ./vendor/bin/run drupal:site-install ``` -To be able to interact with the OpenEuropa Auth mock container you need to add the internal container hostname to the hosts file _of your host OS_. +To be able to interact with the OpenEuropa Authentication mock container you need to add the internal container hostname to the hosts file _of your host OS_. ``` $ echo "127.0.1.1 oeauth-server" >> /etc/hosts ``` diff --git a/composer.json b/composer.json index 0a8caf21..b4bc1e86 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { - "name": "openeuropa/oe_auth", - "description": "Authentication against the OpenEuropa Auth service.", + "name": "openeuropa/oe_authentication", + "description": "Authentication against the OpenEuropa Authentication service.", "type": "drupal-module", "license": "EUPL-1.2", "minimum-stability": "dev", @@ -37,12 +37,12 @@ }, "autoload": { "psr-4": { - "Drupal\\oe_auth\\": "./src/" + "Drupal\\oe_authentication\\": "./src/" } }, "autoload-dev": { "psr-4": { - "Drupal\\Tests\\oe_auth\\": "./tests/" + "Drupal\\Tests\\oe_authentication\\": "./tests/" } }, "extra": { diff --git a/oe_auth.info.yml b/oe_auth.info.yml deleted file mode 100644 index 461615c3..00000000 --- a/oe_auth.info.yml +++ /dev/null @@ -1,5 +0,0 @@ -name: OE Auth -description: Authentication against the OpenEuropa Auth service. -package: OpenEuropa -type: module -core: 8.x diff --git a/oe_auth.services.yml b/oe_auth.services.yml deleted file mode 100644 index 708908c7..00000000 --- a/oe_auth.services.yml +++ /dev/null @@ -1,21 +0,0 @@ -parameters: - oe_auth.pcas.base_url: ~ -services: - oe_auth.authentication: - class: \Drupal\oe_auth\Authentication\Provider\OeAuth - arguments: ['@oe_auth.pcas.factory', '@oe_auth.user_provider'] - tags: - - { name: authentication_provider, provider_id: 'oe_auth', priority: -10, global: TRUE } - - oe_auth.user_provider: - class: \Drupal\oe_auth\UserProvider - arguments: ['@entity_type.manager'] - - oe_auth.route_subscriber: - class: \Drupal\oe_auth\Routing\RouteSubscriber - tags: - - { name: event_subscriber } - - oe_auth.pcas.factory: - class: OpenEuropa\pcas\PCasFactory - arguments: ['@session', '%oe_auth.pcas.base_url%'] diff --git a/oe_authentication.info.yml b/oe_authentication.info.yml new file mode 100644 index 00000000..88451acb --- /dev/null +++ b/oe_authentication.info.yml @@ -0,0 +1,5 @@ +name: OE Authentication +description: Authentication against the OpenEuropa Authentication service. +package: OpenEuropa +type: module +core: 8.x diff --git a/oe_authentication.services.yml b/oe_authentication.services.yml new file mode 100644 index 00000000..a9fb7b3e --- /dev/null +++ b/oe_authentication.services.yml @@ -0,0 +1,21 @@ +parameters: + oe_authentication.pcas.base_url: ~ +services: + oe_authentication.authentication: + class: \Drupal\oe_authentication\Authentication\Provider\OeAuthentication + arguments: ['@oe_authentication.pcas.factory', '@oe_authentication.user_provider'] + tags: + - { name: authentication_provider, provider_id: 'oe_authentication', priority: -10, global: TRUE } + + oe_authentication.user_provider: + class: \Drupal\oe_authentication\UserProvider + arguments: ['@entity_type.manager'] + + oe_authentication.route_subscriber: + class: \Drupal\oe_authentication\Routing\RouteSubscriber + tags: + - { name: event_subscriber } + + oe_authentication.pcas.factory: + class: OpenEuropa\pcas\PCasFactory + arguments: ['@session', '%oe_authentication.pcas.base_url%'] diff --git a/runner.yml.dist b/runner.yml.dist index bd40d370..6c95a543 100644 --- a/runner.yml.dist +++ b/runner.yml.dist @@ -11,7 +11,7 @@ drupal: password: "" post_install: - "./vendor/bin/drush en config_devel -y" - - "./vendor/bin/drush en oe_auth -y" + - "./vendor/bin/drush en oe_authentication -y" - "./vendor/bin/drush cr" settings: settings: @@ -32,7 +32,7 @@ commands: drupal:site-setup: - { task: "mkdir", dir: "${drupal.root}/profiles" } - { task: "mkdir", dir: "${drupal.root}/themes" } - - { task: "symlink", from: "../../..", to: "${drupal.root}/modules/custom/oe_auth" } + - { task: "symlink", from: "../../..", to: "${drupal.root}/modules/custom/oe_authentication" } - { task: "run", command: "drupal:drush-setup" } - { task: "run", command: "drupal:settings-setup" } - { task: "run", command: "setup:phpunit" } diff --git a/services.yml.dist b/services.yml.dist index cfa068a5..1ddad710 100644 --- a/services.yml.dist +++ b/services.yml.dist @@ -1,2 +1,2 @@ parameters: - oe_auth.pcas.base_url: ${authentication.server.base_url} + oe_authentication.pcas.base_url: ${authentication.server.base_url} diff --git a/src/Authentication/Provider/OeAuth.php b/src/Authentication/Provider/OeAuthentication.php similarity index 77% rename from src/Authentication/Provider/OeAuth.php rename to src/Authentication/Provider/OeAuthentication.php index c1039725..11eaaece 100644 --- a/src/Authentication/Provider/OeAuth.php +++ b/src/Authentication/Provider/OeAuthentication.php @@ -2,17 +2,17 @@ declare(strict_types = 1); -namespace Drupal\oe_auth\Authentication\Provider; +namespace Drupal\oe_authentication\Authentication\Provider; use Drupal\Core\Authentication\AuthenticationProviderInterface; -use Drupal\oe_auth\UserProvider; +use Drupal\oe_authentication\UserProvider; use OpenEuropa\pcas\PCasFactory; use Symfony\Component\HttpFoundation\Request; /** * Cookie based authentication provider. */ -class OeAuth implements AuthenticationProviderInterface { +class OeAuthentication implements AuthenticationProviderInterface { /** * The pCas variable. @@ -24,16 +24,16 @@ class OeAuth implements AuthenticationProviderInterface { /** * The user provider variable. * - * @var Drupal\oe_auth\UserProvider + * @var Drupal\oe_authentication\UserProvider */ protected $userProvider; /** - * OeAuth constructor. + * OeAuthentication constructor. * * @param OpenEuropa\pcas\PCasFactory $pCasFactory * The pCas variable. - * @param Drupal\oe_auth\UserProvider $userProvider + * @param Drupal\oe_authentication\UserProvider $userProvider * The user provider variable. */ public function __construct(PCasFactory $pCasFactory, UserProvider $userProvider) { diff --git a/src/Controller/OeAuthController.php b/src/Controller/OeAuthenticationController.php similarity index 89% rename from src/Controller/OeAuthController.php rename to src/Controller/OeAuthenticationController.php index 97bafac4..bb531c94 100644 --- a/src/Controller/OeAuthController.php +++ b/src/Controller/OeAuthenticationController.php @@ -2,7 +2,7 @@ declare(strict_types = 1); -namespace Drupal\oe_auth\Controller; +namespace Drupal\oe_authentication\Controller; use Drupal\Core\Controller\ControllerBase; use Drupal\Core\Session\AccountProxyInterface; @@ -12,9 +12,9 @@ use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; /** - * Returns responses for OE Auth routes. + * Returns responses for OE Authentication routes. */ -class OeAuthController extends ControllerBase { +class OeAuthenticationController extends ControllerBase { /** * The request stack. @@ -52,7 +52,7 @@ public function __construct(RequestStack $requestStack, PCas $pcas, AccountProxy public static function create(ContainerInterface $container) { return new static( $container->get('request_stack'), - $container->get('oe_auth.pcas.factory')->getPCas(), + $container->get('oe_authentication.pcas.factory')->getPCas(), $container->get('current_user') ); } @@ -65,7 +65,7 @@ public static function create(ContainerInterface $container) { */ public function login() { // There is no access to this route for authenticated users, - // Therefore we can directly redirect the user to the OE Auth path. + // Therefore we can directly redirect the user to the OE Authentication path. if ($response = $this->pCas->login()) { return $response; } @@ -102,7 +102,7 @@ protected function doDrupalLogout() { } /** - * Get the redirect object to the OE Auth logout URL. + * Get the redirect object to the OE Authentication logout URL. * * @param string[] $query * The query strings if any. diff --git a/src/OeAuthServiceProvider.php b/src/OeAuthenticationServiceProvider.php similarity index 72% rename from src/OeAuthServiceProvider.php rename to src/OeAuthenticationServiceProvider.php index 53989d51..6225ef6a 100644 --- a/src/OeAuthServiceProvider.php +++ b/src/OeAuthenticationServiceProvider.php @@ -2,15 +2,15 @@ declare(strict_types = 1); -namespace Drupal\oe_auth; +namespace Drupal\oe_authentication; use Drupal\Core\DependencyInjection\ServiceProviderBase; use Drupal\Core\DependencyInjection\ContainerBuilder; /** - * Discovery for the OE Auth library settings. + * Discovery for the OE Authentication library settings. */ -class OeAuthServiceProvider extends ServiceProviderBase { +class OeAuthenticationServiceProvider extends ServiceProviderBase { /** * {@inheritdoc} diff --git a/src/Routing/RouteSubscriber.php b/src/Routing/RouteSubscriber.php index a4e469f7..4659b143 100644 --- a/src/Routing/RouteSubscriber.php +++ b/src/Routing/RouteSubscriber.php @@ -2,7 +2,7 @@ declare(strict_types = 1); -namespace Drupal\oe_auth\Routing; +namespace Drupal\oe_authentication\Routing; use Drupal\Core\Routing\RouteSubscriberBase; use Symfony\Component\Routing\RouteCollection; @@ -20,13 +20,13 @@ protected function alterRoutes(RouteCollection $collection) { if ($route = $collection->get('user.login')) { $defaults = $route->getDefaults(); unset($defaults['_form']); - $defaults['_controller'] = '\Drupal\oe_auth\Controller\OeAuthController::login'; + $defaults['_controller'] = '\Drupal\oe_authentication\Controller\OeAuthenticationController::login'; $route->setDefaults($defaults); } // Replace the core logout route. if ($route = $collection->get('user.logout')) { - $route->setDefault('_controller', '\Drupal\oe_auth\Controller\OeAuthController::logout'); + $route->setDefault('_controller', '\Drupal\oe_authentication\Controller\OeAuthenticationController::logout'); } // Remove these routes as to generate fatal errors wherever // functionality is missing. diff --git a/src/UserProvider.php b/src/UserProvider.php index 134ae8ea..6b27a785 100644 --- a/src/UserProvider.php +++ b/src/UserProvider.php @@ -2,7 +2,7 @@ declare(strict_types = 1); -namespace Drupal\oe_auth; +namespace Drupal\oe_authentication; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\user\UserInterface; @@ -84,12 +84,12 @@ protected function attachRoles(UserInterface $account, PCasUserInterface $pCasUs protected function doLoadAccount(PCasUserInterface $pCasUser) { $mail = $pCasUser->get('cas:email'); if (empty($mail)) { - throw new \Exception('Email address not provided by OE Auth.'); + throw new \Exception('Email address not provided by OE Authentication.'); } $accounts = $this->userStorage->loadByProperties(['mail' => $mail]); if (empty($accounts)) { // Account does not exist, creation of new accounts is handled in. - // @see \Drupal\oe_auth\Controller\OeAuthController::login. + // @see \Drupal\oe_authentication\Controller\OeAuthenticationController::login. return FALSE; } diff --git a/tests/features/login.feature b/tests/features/login.feature index 39fcf0d6..cd5ebac7 100644 --- a/tests/features/login.feature +++ b/tests/features/login.feature @@ -1,13 +1,13 @@ @api -Feature: Login through OE Auth +Feature: Login through OE Authentication In order to be able to access the CMS backend As user of the system - I need to login through OE Auth + I need to login through OE Authentication Scenario: Login Given I am on the homepage Then I click "Log in" - # We are redirected to the mock OE Auth server at this point. + # We are redirected to the mock OE Authentication server at this point. Then I fill in "User" with "Dr. Lektroluv" Then I fill in "Nickname" with "The Man with the Green Mask" Then I fill in "Password" with "Em0lotion" From 6b4998545f63247c963129fa374c967704c1de8a Mon Sep 17 00:00:00 2001 From: Yemoko Date: Mon, 20 Aug 2018 13:02:23 +0000 Subject: [PATCH 2/4] OPENEUROPA-1159 Coding style. --- src/Controller/OeAuthenticationController.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Controller/OeAuthenticationController.php b/src/Controller/OeAuthenticationController.php index bb531c94..ca0cb925 100644 --- a/src/Controller/OeAuthenticationController.php +++ b/src/Controller/OeAuthenticationController.php @@ -65,7 +65,8 @@ public static function create(ContainerInterface $container) { */ public function login() { // There is no access to this route for authenticated users, - // Therefore we can directly redirect the user to the OE Authentication path. + // Therefore we can directly redirect the user to + // the OE Authentication path. if ($response = $this->pCas->login()) { return $response; } From c215db78264e055905a1cc9ca32071a16a03df25 Mon Sep 17 00:00:00 2001 From: Yemoko Date: Mon, 20 Aug 2018 14:58:25 +0000 Subject: [PATCH 3/4] OPENEUROPA-1159: Update paths in drone file. --- .drone.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.drone.yml b/.drone.yml index 0d527d1d..a8e9cec9 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,12 +1,12 @@ workspace: base: /test - path: oe_auth + path: oe_authentication services: web: image: fpfis/httpd-php-dev:7.1 environment: - - DOCUMENT_ROOT=/test/oe_auth + - DOCUMENT_ROOT=/test/oe_authentication mysql: image: percona/percona-server:5.6 environment: From 2f6226901306e5d7e46fa8cbc7af58b7b79c50ec Mon Sep 17 00:00:00 2001 From: Yemoko Date: Mon, 20 Aug 2018 15:32:45 +0000 Subject: [PATCH 4/4] OPENEUROPA-1159: Update changelog. --- CHANGELOG.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b44d3b59..9fee3455 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,20 +1,20 @@ # Change Log -## [0.2.0](https://github.com/openeuropa/oe_auth/tree/0.2.0) (2018-06-25) -[Full Changelog](https://github.com/openeuropa/oe_auth/compare/0.1.0...0.2.0) +## [0.2.0](https://github.com/openeuropa/oe_authentication/tree/0.2.0) (2018-06-25) +[Full Changelog](https://github.com/openeuropa/oe_authentication/compare/0.1.0...0.2.0) **Merged pull requests:** -- OPENEUROPA-679: Make authentication service endpoint configurable [\#6](https://github.com/openeuropa/oe_auth/pull/6) ([voidtek](https://github.com/voidtek)) +- OPENEUROPA-679: Make authentication service endpoint configurable [\#6](https://github.com/openeuropa/oe_authentication/pull/6) ([voidtek](https://github.com/voidtek)) -## [0.1.0](https://github.com/openeuropa/oe_auth/tree/0.1.0) (2018-06-19) +## [0.1.0](https://github.com/openeuropa/oe_authentication/tree/0.1.0) (2018-06-19) **Merged pull requests:** -- Add CHANGELOG.md for 0.1.0 release. [\#5](https://github.com/openeuropa/oe_auth/pull/5) ([ademarco](https://github.com/ademarco)) -- OPENEUROPA-657: Update license and make it compliant with packagist.org's recommandations [\#4](https://github.com/openeuropa/oe_auth/pull/4) ([drupol](https://github.com/drupol)) -- OPENEUROPA-657: Rename from eu\_login to oe\_auth. [\#3](https://github.com/openeuropa/oe_auth/pull/3) ([drupol](https://github.com/drupol)) -- OPENEUROPA-657: Rename the module from eu\_login to oe\_auth. [\#2](https://github.com/openeuropa/oe_auth/pull/2) ([drupol](https://github.com/drupol)) -- OPENEUROPA-204: Initial work [\#1](https://github.com/openeuropa/oe_auth/pull/1) ([sandervd](https://github.com/sandervd)) +- Add CHANGELOG.md for 0.1.0 release. [\#5](https://github.com/openeuropa/oe_authentication/pull/5) ([ademarco](https://github.com/ademarco)) +- OPENEUROPA-657: Update license and make it compliant with packagist.org's recommandations [\#4](https://github.com/openeuropa/oe_authentication/pull/4) ([drupol](https://github.com/drupol)) +- OPENEUROPA-657: Rename from eu\_login to oe\_auth. [\#3](https://github.com/openeuropa/oe_authentication/pull/3) ([drupol](https://github.com/drupol)) +- OPENEUROPA-657: Rename the module from eu\_login to oe\_auth. [\#2](https://github.com/openeuropa/oe_authentication/pull/2) ([drupol](https://github.com/drupol)) +- OPENEUROPA-204: Initial work [\#1](https://github.com/openeuropa/oe_authentication/pull/1) ([sandervd](https://github.com/sandervd))