Skip to content

Commit

Permalink
Merge pull request #11 from openeuropa/OPENEUROPA-758
Browse files Browse the repository at this point in the history
OPENEUROPA-758: Use single entry point object instead of requiring service file
  • Loading branch information
voidtek authored Aug 13, 2018
2 parents 51bdf61 + 40de4ca commit fb67a00
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 76 deletions.
3 changes: 3 additions & 0 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,7 @@ pipeline:
group: test
image: fpfis/httpd-php-dev:7.1
commands:
# Reset permission since installation runs as root. @todo Fix this.
- ./vendor/bin/drush -y config-set system.performance css.preprocess 0
- ./vendor/bin/drush -y config-set system.performance js.preprocess 0
- ./vendor/bin/behat
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,17 @@ The recommended way of installing the OpenEuropa Auth module is via a [Composer]
composer require openeuropa/oe_auth
```

Before being able to use the module, you will need to specify the ECAS service base URL
in your Drupal installation's `./sites/default/default.services.yml` file as shown below:

```
parameters:
oe_auth.pcas.base_url: http://my-ecas-service.com
```

For more information about how to override service parameters in Drupal 8
check the [related documentation page](https://www.drupal.org/docs/8/api/services-and-dependency-injection/services-and-dependency-injection-in-drupal-8)

### Enable the module

In order to enable the module in your project run:
Expand Down
16 changes: 6 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"php": "^7.1",
"drupal/core": "~8.6@alpha",
"openeuropa/pcas": "dev-master",
"openeuropa/pcas": "~0.1",
"php": "^7.1",
"php-http/guzzle6-adapter": "^1.1"
},
"require-dev": {
Expand All @@ -20,9 +20,9 @@
"drupal/drupal-extension": "^4.0.0@alpha",
"drush/drush": "^9",
"nikic/php-parser": "~3",
"openeuropa/code-review": "^0.2",
"openeuropa/task-runner": "^0.7",
"webflo/drupal-core-require-dev": "~8.6@alpha"
"openeuropa/code-review": "~0.2",
"openeuropa/drupal-core-require-dev": "~8.6",
"openeuropa/task-runner": "~0.7"
},
"scripts": {
"drupal-scaffold": "DrupalComposer\\DrupalScaffold\\Plugin::scaffold",
Expand All @@ -47,11 +47,7 @@
},
"extra": {
"composer-exit-on-patch-failure": true,
"patches": {
"drupal/core": {
"https://www.drupal.org/project/drupal/issues/2943172": "https://www.drupal.org/files/issues/2018-07-05/2943172-kernel-test-base-3.patch"
}
},
"enable-patching": true,
"installer-paths": {
"build/core": ["type:drupal-core"],
"build/profiles/contrib/{$name}": ["type:drupal-profile"],
Expand Down
7 changes: 2 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
version: '2'
services:

web:
image: fpfis/httpd-php-dev:7.1
working_dir: /var/www/html
Expand All @@ -11,13 +10,11 @@ services:
environment:
XDEBUG_CONFIG: "remote_enable=1 remote_host=${DOCKER_HOST_IP} remote_port=9000 idekey=PHPSTORM remote_autostart=1"
PHP_IDE_CONFIG: "serverName=Test"

mysql:
image: percona/percona-server:5.6
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: "yes"

authentication:
image: openeuropa/pcas-server:latest
expose:
- 8001
ports:
- 8001:8001
16 changes: 11 additions & 5 deletions oe_auth.services.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
parameters:
oe_auth.pcas.base_url: ~
services:
oeauth.authentication:
oe_auth.authentication:
class: \Drupal\oe_auth\Authentication\Provider\OeAuth
arguments: ['@pcas', '@oeauth.userprovider']
arguments: ['@oe_auth.pcas.factory', '@oe_auth.user_provider']
tags:
- { name: authentication_provider, provider_id: 'oeauth', priority: -10, global: TRUE }
- { name: authentication_provider, provider_id: 'oe_auth', priority: -10, global: TRUE }

oeauth.userprovider:
oe_auth.user_provider:
class: \Drupal\oe_auth\UserProvider
arguments: ['@entity_type.manager']

oeauth.route_subscriber:
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%']
2 changes: 2 additions & 0 deletions runner.yml.dist
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
drupal:
root: "build"
base_url: "http://web:8080/build"
site:
name: "OpenEuropa"
database:
host: "mysql"
port: "3306"
Expand Down
49 changes: 1 addition & 48 deletions services.yml.dist
Original file line number Diff line number Diff line change
@@ -1,49 +1,2 @@
parameters:
p_cas:
logger_startup_message: ''
protocol:
login:
uri: ${authentication.server.base_url}/login
query: []
allowed_parameters:
- service
- renew
- gateway
servicevalidate:
uri: ${authentication.server.base_url}/serviceValidate
query: []
allowed_parameters:
- service
- ticket
- pgtUrl
- renew
- format
logout:
uri: ${authentication.server.base_url}/logout
query: []
allowed_parameters:
- service

services:
pcas:
class: OpenEuropa\pcas\PCas
arguments: ['%p_cas%', '@?pcas.httpclient', '@?pcas.protocol', '@?session']
public: true

pcas.httpclient:
class: OpenEuropa\pcas\Http\Client
factory: 'pcas.httpclientfactory:getHttpClient'

pcas.protocol:
class: OpenEuropa\pcas\Cas\Protocol\V2\CasProtocolV2
arguments: ['@pcas.userfactory', '@pcas.serializerfactory']
public: true

pcas.userfactory:
class: OpenEuropa\pcas\Security\Core\User\PCasUserFactory

pcas.serializerfactory:
class: OpenEuropa\pcas\Utils\PCasSerializerFactory

pcas.httpclientfactory:
class: OpenEuropa\pcas\Http\HttpClientFactory
oe_auth.pcas.base_url: ${authentication.server.base_url}
8 changes: 4 additions & 4 deletions src/Authentication/Provider/OeAuth.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use Drupal\Core\Authentication\AuthenticationProviderInterface;
use Drupal\oe_auth\UserProvider;
use OpenEuropa\pcas\PCas;
use OpenEuropa\pcas\PCasFactory;
use Symfony\Component\HttpFoundation\Request;

/**
Expand All @@ -31,13 +31,13 @@ class OeAuth implements AuthenticationProviderInterface {
/**
* OeAuth constructor.
*
* @param OpenEuropa\pcas\PCas $pCas
* @param OpenEuropa\pcas\PCasFactory $pCasFactory
* The pCas variable.
* @param Drupal\oe_auth\UserProvider $userProvider
* The user provider variable.
*/
public function __construct(PCas $pCas, UserProvider $userProvider) {
$this->pCas = $pCas;
public function __construct(PCasFactory $pCasFactory, UserProvider $userProvider) {
$this->pCas = $pCasFactory->getPCas();
$this->userProvider = $userProvider;
}

Expand Down
8 changes: 4 additions & 4 deletions src/Controller/OeAuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ class OeAuthController extends ControllerBase {
*
* @param \Symfony\Component\HttpFoundation\RequestStack $requestStack
* The request stack.
* @param \OpenEuropa\pcas\PCas $pCas
* @param \OpenEuropa\pcas\PCas $pcas
* The pCas variable.
* @param \Drupal\Core\Session\AccountProxyInterface $current_user
* The current user.
*/
public function __construct(RequestStack $requestStack, PCas $pCas, AccountProxyInterface $current_user) {
public function __construct(RequestStack $requestStack, PCas $pcas, AccountProxyInterface $current_user) {
$this->requestStack = $requestStack;
$this->pCas = $pCas;
$this->pCas = $pcas;
$this->currentUser = $current_user;
}

Expand All @@ -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('pcas'),
$container->get('oe_auth.pcas.factory')->getPCas(),
$container->get('current_user')
);
}
Expand Down

0 comments on commit fb67a00

Please sign in to comment.