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