Commit bbe06114 authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

Passage à ZF3 MAIS NON TESTÉ

parent 8f0a6cae
.idea
vendor
\ No newline at end of file
{ {
"name": "unicaen/oauth", "name": "unicaen/oauth",
"description": "Serveur OAuth2 authentifiant soit via LDAP, soit via CAS", "description": "Serveur OAuth2 authentifiant soit via LDAP, soit via CAS",
"license": "proprietary",
"repositories": [ "repositories": [
{ {
"type": "vcs", "type": "composer",
"url": "https://svn.unicaen.fr/svn/UnicaenLdap" "url": "https://gest.unicaen.fr/packagist"
} }
], ],
"require": { "require": {
"zendframework/zend-servicemanager": "~2.4 || ^2.5 || ^7.0", "zendframework/zend-servicemanager": "^3.4",
"zendframework/zend-authentication": "~2.4 || ^2.5 || ^7.0", "zendframework/zend-authentication": "^2.7",
"zfcampus/zf-oauth2": "^1.4.0", "zfcampus/zf-oauth2": "^1.5",
"unicaen/ldap": "~2.1", "unicaen/ldap": "^3.1",
"jasig/phpcas": "^1.3.4" "jasig/phpcas": "^1.4"
}, },
"autoload": { "autoload": {
"psr-0": { "psr-0": {
......
This diff is collapsed.
...@@ -2,35 +2,35 @@ ...@@ -2,35 +2,35 @@
namespace UnicaenOauth; namespace UnicaenOauth;
return array( return [
'router' => array( 'router' => [
'routes' => array( 'routes' => [
'login-cas' => array( 'login-cas' => [
'type' => 'Literal', 'type' => 'Literal',
'options' => array( 'options' => [
'route' => '/cas/login', 'route' => '/cas/login',
'defaults' => array( 'defaults' => [
'controller' => __NAMESPACE__ . '\Controller\Cas', 'controller' => __NAMESPACE__ . '\Controller\Cas',
'action' => 'login', 'action' => 'login',
), ],
), ],
), ],
), ],
), ],
'controllers' => array( 'controllers' => [
'factories' => array( 'factories' => [
__NAMESPACE__ . '\Controller\Cas' => __NAMESPACE__ . '\Controller\CasControllerFactory', __NAMESPACE__ . '\Controller\Cas' => __NAMESPACE__ . '\Controller\CasControllerFactory',
), ],
), ],
'service_manager' => array( 'service_manager' => [
'factories' => array( 'factories' => [
'service.cas' => __NAMESPACE__ . '\Cas\CasServiceFactory', 'service.cas' => __NAMESPACE__ . '\Cas\CasServiceFactory',
'ZF\OAuth2\Adapter\PdoAdapter' => __NAMESPACE__ . '\OAuth2\Adapter\StorageAdapterFactory', 'ZF\OAuth2\Adapter\PdoAdapter' => __NAMESPACE__ . '\OAuth2\Adapter\StorageAdapterFactory',
) ]
), ],
'view_manager' => array( 'view_manager' => [
'template_path_stack' => array( 'template_path_stack' => [
__DIR__ . '/../view', __DIR__ . '/../view',
), ],
), ],
); ];
\ No newline at end of file \ No newline at end of file
<?php <?php
return array( return [
'unicaen-oauth' => [ 'unicaen-oauth' => [
'cas' => [ 'cas' => [
'host' => 'host.domain.fr', 'host' => 'host.domain.fr',
...@@ -15,4 +15,4 @@ return array( ...@@ -15,4 +15,4 @@ return array(
*/ */
//'usurpation_allowed_usernames' => array(), //'usurpation_allowed_usernames' => array(),
], ],
); ];
\ No newline at end of file \ No newline at end of file
...@@ -2,12 +2,9 @@ ...@@ -2,12 +2,9 @@
namespace UnicaenOauth\Cas; namespace UnicaenOauth\Cas;
use phpCAS; use phpCAS;
use Zend\ServiceManager\ServiceLocatorAwareTrait;
class CasService class CasService
{ {
use ServiceLocatorAwareTrait;
private $config; private $config;
public function __construct(array $config) public function __construct(array $config)
......
...@@ -2,18 +2,14 @@ ...@@ -2,18 +2,14 @@
namespace UnicaenOauth\Cas; namespace UnicaenOauth\Cas;
use Zend\ServiceManager\FactoryInterface; use Interop\Container\ContainerInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
class CasServiceFactory implements FactoryInterface class CasServiceFactory
{ {
public function createService(ServiceLocatorInterface $serviceLocator) public function __invoke(ContainerInterface $container)
{ {
$config = $serviceLocator->get('config'); $config = $container->get('config');
$service = new CasService($config['unicaen-oauth']['cas']); return new CasService($config['unicaen-oauth']['cas']);
$service->setServiceLocator($serviceLocator);
return $service;
} }
} }
\ No newline at end of file
...@@ -2,14 +2,13 @@ ...@@ -2,14 +2,13 @@
namespace UnicaenOauth\Controller; namespace UnicaenOauth\Controller;
use Zend\ServiceManager\FactoryInterface; use Interop\Container\ContainerInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
class CasControllerFactory implements FactoryInterface class CasControllerFactory
{ {
public function createService(ServiceLocatorInterface $serviceLocator) public function __invoke(ContainerInterface $container)
{ {
$casService = $serviceLocator->getServiceLocator()->get('service.cas'); $casService = $container->get('service.cas');
$controller = new CasController(); $controller = new CasController();
$controller->setServiceCas($casService); $controller->setServiceCas($casService);
......
...@@ -30,6 +30,16 @@ class StorageAdapter extends PdoAdapter ...@@ -30,6 +30,16 @@ class StorageAdapter extends PdoAdapter
private $usernameUsurpateur; private $usernameUsurpateur;
private $usernameUsurpe; private $usernameUsurpe;
/**
* StorageAdapter constructor.
* @param mixed $connection
* @param array $config
*/
public function __construct($connection, $config = [])
{
parent::__construct($connection, $config);
}
/** /**
* Redéfinition. * Redéfinition.
* *
......
...@@ -2,21 +2,15 @@ ...@@ -2,21 +2,15 @@
namespace UnicaenOauth\OAuth2\Adapter; namespace UnicaenOauth\OAuth2\Adapter;
use Interop\Container\ContainerInterface;
use UnicaenOauth\Cas\CasService; use UnicaenOauth\Cas\CasService;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
use ZF\OAuth2\Controller\Exception; use ZF\OAuth2\Controller\Exception;
class StorageAdapterFactory implements FactoryInterface class StorageAdapterFactory
{ {
/** public function __invoke(ContainerInterface $container)
* @param ServiceLocatorInterface $services
* @throws \ZF\OAuth2\Controller\Exception\RuntimeException
* @return \UnicaenOauth\OAuth2\Adapter\PdoAdapter
*/
public function createService(ServiceLocatorInterface $services)
{ {
$config = $services->get('Config'); $config = $container->get('Config');
if (!isset($config['zf-oauth2']['db']) || empty($config['zf-oauth2']['db'])) { if (!isset($config['zf-oauth2']['db']) || empty($config['zf-oauth2']['db'])) {
throw new Exception\RuntimeException( throw new Exception\RuntimeException(
...@@ -43,14 +37,14 @@ class StorageAdapterFactory implements FactoryInterface ...@@ -43,14 +37,14 @@ class StorageAdapterFactory implements FactoryInterface
/** /**
* Inject LDAP People Service. * Inject LDAP People Service.
*/ */
$ldapPeopleService = $services->get('ldapServicePeople'); $ldapPeopleService = $container->get('ldapServicePeople');
/* @var $ldapPeopleService \UnicaenLdap\Service\People */ /* @var $ldapPeopleService \UnicaenLdap\Service\People */
$adapter->setLdapService($ldapPeopleService); $adapter->setLdapService($ldapPeopleService);
/** /**
* Inject CAS service. * Inject CAS service.
*/ */
$casService = $services->get('service.cas'); $casService = $container->get('service.cas');
/* @var $casService CasService */ /* @var $casService CasService */
$adapter->setServiceCas($casService); $adapter->setServiceCas($casService);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment