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

Import initial

parent 6808d882
<?php
namespace UnicaenAuth;
use Zend\ModuleManager\Feature\AutoloaderProviderInterface;
use Zend\ModuleManager\Feature\ConfigProviderInterface;
use Zend\ModuleManager\Feature\ServiceProviderInterface;
use Zend\ModuleManager\Feature\ViewHelperProviderInterface;
use Zend\View\HelperPluginManager;
define('__VENDOR_DIR__', dirname(dirname(__DIR__)));
/**
* Point d'entrée du module d'authentification Unicaen.
*
* @author Bertrand GAUTHIER <bertrand.gauthier@unicaen.fr>
*/
class Module implements ConfigProviderInterface, ViewHelperProviderInterface, ServiceProviderInterface
{
/**
*
* @return array
* @see ConfigProviderInterface
*/
public function getConfig()
{
return include __DIR__ . '/config/module.config.php';
}
/**
*
* @return array
* @see AutoloaderProviderInterface
*/
public function getAutoloaderConfig()
{
return array(
'Zend\Loader\ClassMapAutoloader' => array(
__DIR__ . '/autoload_classmap.php',
),
'Zend\Loader\StandardAutoloader' => array(
'namespaces' => array(
__NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
),
),
);
}
/**
* This method is called once the MVC bootstrapping is complete,
* after the "loadModule.post" event, once $application->bootstrap() is called.
*
* @param EventInterface $e
* @see BootstrapListenerInterface
*/
public function onBootstrap(\Zend\EventManager\EventInterface $e) /* @var \Zend\Mvc\MvcEvent $e */
{
$application = $e->getApplication();
/* @var $services \Zend\ServiceManager\ServiceManager */
$services = $application->getServiceManager();
// /* @var $vhm HelperPluginManager */
// $vhm = $services->get('view_helper_manager');
// /* @var $nvh Navigation */
// $nvh = $vhm->get('navigation');
// /* @var $authorizeService \BjyAuthorize\Service\Authorize */
// $authorizeService = $services->get('BjyAuthorize\Service\Authorize');
// $nvh->setAcl($authorizeService->getAcl())->setRole($authorizeService->getIdentity());
/* @var $options Options\ModuleOptions */
$options = $services->get('unicaen-auth_module_options');
// si l'auth CAS est demandée, modif de la route de connexion pour zapper le formulaire
if ($options->getCasAuthenticationActivated()) {
/* @var $router \Zend\Mvc\Router\Http\TreeRouteStack */
$router = $services->get('router');
$router->addRoutes(array(
// remplace les routes existantes (cf. config du module)
'zfcuser' => array(
'type' => 'Literal',
'priority' => 1000,
'options' => array(
'route' => '/utilisateur',
'defaults' => array(
'controller' => 'zfcuser',
'action' => 'index',
),
),
'may_terminate' => true,
'child_routes' => array(
'login' => array(
'type' => 'Literal',
'options' => array(
'route' => '/connexion',
'defaults' => array(
'controller' => 'zfcuser',
'action' => 'authenticate', // zappe l'action 'login'
),
),
),
'logout' => array(
'type' => 'Literal',
'options' => array(
'route' => '/deconnexion',
'defaults' => array(
'controller' => 'zfcuser',
'action' => 'logout',
),
),
),
),
)
));
}
}
/**
*
* @return array
* @see ViewHelperProviderInterface
*/
public function getViewHelperConfig()
{
return array(
'factories' => array(
'appConnection' => function (HelperPluginManager $sm) {
return new View\Helper\AppConnection();
},
'userConnection' => function (HelperPluginManager $sm) {
return new View\Helper\UserConnection($sm->getServiceLocator()->get('zfcuser_auth_service'));
},
'userCurrent' => function (HelperPluginManager $sm) {
return new View\Helper\UserCurrent($sm->getServiceLocator()->get('zfcuser_auth_service'));
},
'userStatus' => function (HelperPluginManager $sm) {
return new View\Helper\UserStatus($sm->getServiceLocator()->get('zfcuser_auth_service'));
},
// 'userProfile' => function (HelperPluginManager $sm) {
// $helper = new View\Helper\UserProfile($sm->getServiceLocator()->get('zfcuser_auth_service'));
// $helper->setIdentityProvider($sm->getServiceLocator()->get('BjyAuthorize\Service\Authorize')->getIdentityProvider());
// return $helper;
// },
'userInfo' => function (HelperPluginManager $sm) {
$helper = new View\Helper\UserInfo($sm->getServiceLocator()->get('zfcuser_auth_service'));
$helper->setServiceStructure($sm->getServiceLocator()->get('ldap_structure_service'));
return $helper;
},
),
);
}
/**
*
* @return array
* @see ServiceProviderInterface
*/
public function getServiceConfig()
{
return array(
'factories' => array(
'unicaen-auth_module_options' => function($sm) {
$config = $sm->get('Configuration');
return new Options\ModuleOptions(isset($config['unicaen-auth']) ? $config['unicaen-auth'] : array());
},
'UnicaenAuth\Authentication\Adapter\Ldap' => function() {
return new Authentication\Adapter\Ldap();
},
'UnicaenAuth\Authentication\Adapter\Cas' => function() {
return new Authentication\Adapter\Cas();
},
'UnicaenAuth\Authentication\Storage\Db' => function() {
return new Authentication\Storage\Db();
},
'UnicaenAuth\Authentication\Storage\Ldap' => function() {
return new Authentication\Storage\Ldap();
},
'unicaen-auth_user_service' => function () {
return new Service\User();
},
'zfcuser_auth_service' => function ($sm) {
return new \Zend\Authentication\AuthenticationService(
$sm->get('UnicaenAuth\Authentication\Storage\Mixed'),
$sm->get('ZfcUser\Authentication\Adapter\AdapterChain')
);
},
'UnicaenAuth\View\UnauthorizedStrategy' => function (\Zend\ServiceManager\ServiceLocatorInterface $serviceLocator) {
$config = $serviceLocator->get('Config');
return new View\UnauthorizedStrategy($config['bjyauthorize']['template']);
},
'UnicaenAuth\Authentication\Storage\Mixed' => function($sm) {
$storage = new Authentication\Storage\Mixed();
$storage->setLdapStorage($sm->get('UnicaenAuth\Authentication\Storage\Ldap'))
->setDbStorage($sm->get('UnicaenAuth\Authentication\Storage\Db'));
return $storage;
},
'ZfcUser\Authentication\Adapter\AdapterChain' => 'UnicaenAuth\Authentication\Adapter\AdapterChainServiceFactory',
),
);
}
private function poeditPatch()
{
$element = new \Zend\Form\Element\Text('tmp');
$element->setLabel("Sign In")
->setLabel("Username")
->setLabel("Password");
}
}
<?php
// Generated by ZF2's ./bin/classmap_generator.php
return array(
'UnicaenAuth\Authentication\Storage\Ldap' => __DIR__ . '/src/UnicaenAuth/Authentication/Storage/Ldap.php',
'UnicaenAuth\Authentication\Storage\Db' => __DIR__ . '/src/UnicaenAuth/Authentication/Storage/Db.php',
'UnicaenAuth\Authentication\Storage\Mixed' => __DIR__ . '/src/UnicaenAuth/Authentication/Storage/Mixed.php',
'UnicaenAuth\Authentication\Adapter\AdapterChainServiceFactory' => __DIR__ . '/src/UnicaenAuth/Authentication/Adapter/AdapterChainServiceFactory.php',
'UnicaenAuth\Authentication\Adapter\Ldap' => __DIR__ . '/src/UnicaenAuth/Authentication/Adapter/Ldap.php',
'UnicaenAuth\Authentication\Adapter\Db' => __DIR__ . '/src/UnicaenAuth/Authentication/Adapter/Db.php',
'UnicaenAuth\Authentication\Adapter\Cas' => __DIR__ . '/src/UnicaenAuth/Authentication/Adapter/Cas.php',
'UnicaenAuth\Options\AuthenticationOptionsInterface' => __DIR__ . '/src/UnicaenAuth/Options/AuthenticationOptionsInterface.php',
'UnicaenAuth\Options\ModuleOptions' => __DIR__ . '/src/UnicaenAuth/Options/ModuleOptions.php',
'UnicaenAuth\Entity\Ldap\PeopleAdapter' => __DIR__ . '/src/UnicaenAuth/Entity/Ldap/PeopleAdapter.php',
'UnicaenAuth\View\UnauthorizedStrategy' => __DIR__ . '/src/UnicaenAuth/View/UnauthorizedStrategy.php',
'UnicaenAuth\View\Helper\AppConnection' => __DIR__ . '/src/UnicaenAuth/View/Helper/AppConnection.php',
'UnicaenAuth\View\Helper\UserStatus' => __DIR__ . '/src/UnicaenAuth/View/Helper/UserStatus.php',
'UnicaenAuth\View\Helper\UserProfile' => __DIR__ . '/src/UnicaenAuth/View/Helper/UserProfile.php',
'UnicaenAuth\View\Helper\UserInfo' => __DIR__ . '/src/UnicaenAuth/View/Helper/UserInfo.php',
'UnicaenAuth\View\Helper\UserCurrent' => __DIR__ . '/src/UnicaenAuth/View/Helper/UserCurrent.php',
'UnicaenAuth\View\Helper\UserConnection' => __DIR__ . '/src/UnicaenAuth/View/Helper/UserConnection.php',
'UnicaenAuth\View\Helper\UserAbstract' => __DIR__ . '/src/UnicaenAuth/View/Helper/UserAbstract.php',
'UnicaenAuth\Module' => __DIR__ . '/Module.php',
);
\ No newline at end of file
{
"name": "unicaen/unicaen-auth",
"description": "Module d'authentification pour les applis ZF2 de l'UCBN",
"type": "library",
"authors": [
{
"name": "Bertrand GAUTHIER",
"email": "bertrand.gauthier@unicaen.fr"
}
],
"require": {
"php": ">=5.3.3",
"zf-commons/zfc-user-doctrine-orm": "dev-master",
"gorg/phpcas": "dev-master",
"unicaen/unicaen-app": "dev-trunk",
},
"autoload": {
"psr-0": {
"UnicaenAuth": "src/"
},
"classmap": [
"./Module.php"
]
}
}
<?php
$settings = array(
);
$zfcuserSettings = array(
/**
* Enable registration
* Allows users to register through the website.
* Accepted values: boolean true or false
*/
'enable_registration' => true,
/**
* Modes for authentication identity match
* Specify the allowable identity modes, in the order they should be
* checked by the Authentication plugin.
* Default value: array containing 'email'
* Accepted values: array containing one or more of: email, username
*/
'auth_identity_fields' => array('username'),
/**
* Login Redirect Route
* Upon successful login the user will be redirected to the entered route
* Default value: 'zfcuser'
* Accepted values: A valid route name within your application
*/
'login_redirect_route' => 'home',
/**
* Logout Redirect Route
* Upon logging out the user will be redirected to the enterd route
* Default value: 'zfcuser/login'
* Accepted values: A valid route name within your application
*/
'logout_redirect_route' => 'home',
/**
* Enable Username
* Enables username field on the registration form, and allows users to log
* in using their username OR email address. Default is false.
* Accepted values: boolean true or false
*/
'enable_username' => true,
/**
* Enable Display Name
* Enables a display name field on the registration form, which is persisted
* in the database. Default value is false.
* Accepted values: boolean true or false
*/
'enable_display_name' => true,
// /**
// * Authentication Adapters
// * Specify the adapters that will be used to try and authenticate the user
// * Default value: array containing 'ZfcUser\Authentication\Adapter\Db' with priority 100
// * Accepted values: array containing services that implement 'ZfcUser\Authentication\Adapter\ChainableAdapter'
// */
// 'auth_adapters' => array(
//// 300 => 'UnicaenAuth\Authentication\Adapter\Cas',
// 200 => 'UnicaenAuth\Authentication\Adapter\Ldap',
//// 100 => 'UnicaenAuth\Authentication\Adapter\Db',
// ),
);
return array(
'zfcuser' => $zfcuserSettings,
'unicaen-auth' => $settings,
'view_manager' => array(
'template_path_stack' => array(
'unicaen-user' => __DIR__ . '/../view',
),
),
'service_manager' => array(
'factories' => array(
'translator' => '\UnicaenApp\I18n\Translator\TranslatorServiceFactory',
),
),
'translator' => array(
'locale' => 'fr_FR',
'translation_file_patterns' => array(
array(
'type' => 'gettext',
'base_dir' => __DIR__ . '/../language',
'pattern' => '%s.mo',
),
),
),
'router' => array(
'routes' => array(
'unicaen-auth' => array(
'type' => 'Literal',
'priority' => 2000,
'options' => array(
'route' => '/utilisateur/generer-sesame',
'defaults' => array(
'controller' => 'unicaen-user',
'action' => 'generer-sesame',
),
),
'may_terminate' => true,
'child_routes' => array(
'query' => array(
'type' => 'Query',
),
),
),
'zfcuser' => array(
'type' => 'Literal',
'priority' => 1000,
'options' => array(
'route' => '/utilisateur',
'defaults' => array(
'controller' => 'zfcuser',
'action' => 'index',
),
),
'may_terminate' => true,
'child_routes' => array(
'login' => array(
'type' => 'Literal',
'options' => array(
'route' => '/connexion',
'defaults' => array(
'controller' => 'zfcuser',
'action' => 'login',
),
),
),
'logout' => array(
'type' => 'Literal',
'options' => array(
'route' => '/deconnexion',
'defaults' => array(
'controller' => 'zfcuser',
'action' => 'logout',
),
),
),
),
),
),
),
// All navigation-related configuration is collected in the 'navigation' key
'navigation' => array(
// The DefaultNavigationFactory we configured uses 'default' as the sitemap key
'default' => array(
// And finally, here is where we define our page hierarchy
'home' => array(
'pages' => array(
'login' => array(
'label' => "Se connecter",
'route' => 'zfcuser/login',
'visible' => false,
),
'register' => array(
'label' => "S'enregistrer",
'route' => 'zfcuser/register',
'visible' => false,
),
),
),
),
),
);
<?php
/**
* UnicaenAuth Configuration
*
* If you have a ./config/autoload/ directory set up for your project, you can
* drop this config file in it and change the values as you wish.
*/
$settings = array(
/**
* Activation ou non de l'authentification CAS.
*/
'cas_authentication_activated' => false,
/**
* Connexion au serveur CAS.
*/
'cas_connection_infos' => array(
'hostname' => 'cas.unicaen.fr',
'port' => 443,
'version' => "2.0",
'uri' => "",
'debug' => false,
),
/**
* Mot de passe sésame, chiffré avec l'algo Bcrypt
* $bcrypt = new \Zend\Crypt\Password\Bcrypt();
* echo $bcrypt->create('votreMotDePasseSesame');
*/
'sesame_password' => '$2y$14$Kvq9KHfDRMFayA6SJZL8tO4rjNjOtOeYwI/.GoaYgY2IxUP0rkdIS',
/**
* Flag indiquant si l'utilisateur authenitifié avec succès via l'annuaire LDAP doit
* être enregistré/mis à jour dans la table des utilisateurs de l'appli.
*/
'save_ldap_user_in_database' => true,
);
$zfcuserSettings = array(
/**
* Enable registration
* Allows users to register through the website.
* Accepted values: boolean true or false
*/
'enable_registration' => true,
);
/**
* You do not need to edit below this line
*/
return array(
'unicaen-auth' => $settings,
'zfcuser' => $zfcuserSettings,
);
msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2012-11-23 13:56+0100\n"
"PO-Revision-Date: 2012-11-23 14:21+0100\n"
"Last-Translator: Université de Caen Basse Normandie\n"
"Language-Team: \n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Poedit-KeywordsList: translate;setLabel\n"
"X-Poedit-Basepath: .\n"
"X-Poedit-Language: French\n"
"X-Poedit-Country: FRANCE\n"
"X-Poedit-SourceCharset: utf-8\n"
"X-Poedit-SearchPath-0: ..\n"
"X-Poedit-SearchPath-1: ../../../zf-commons/zfc-user\n"
#: ../Module.php:200
msgid "Sign In"
msgstr "Sign In"
#: ../Module.php:201
msgid "Username"
msgstr "Username"
#: ../Module.php:202
msgid "Password"
msgstr "Password"
#: ../src/UnicaenAuth/View/Helper/UserStatus.php:96
#: ../src/UnicaenAuth/View/Helper/UserProfile.php:65
msgid "Aucun"
msgstr "None"
#: ../src/UnicaenAuth/View/Helper/UserProfile.php:46
msgid "Profil"
msgstr "Profile"
#: ../src/UnicaenAuth/View/Helper/UserInfo.php:52
msgid "Affectations administratives"
msgstr "Display authentication form"
#: ../src/UnicaenAuth/View/Helper/UserInfo.php:53
msgid "Affectations recherche"
msgstr ""
#: ../src/UnicaenAuth/View/Helper/UserInfo.php:54
msgid "Responsabilités"
msgstr "Responsabilities"
#: ../src/UnicaenAuth/View/Helper/UserInfo.php:65
msgid "Aucune affectation trouvée."
msgstr ""
#: ../src/UnicaenAuth/View/Helper/UserInfo.php:96
msgid "Aucune affectation disponible."
msgstr ""
#: ../src/UnicaenAuth/View/Helper/UserConnection.php:49
msgid "Connexion"
msgstr "Connection"
#: ../src/UnicaenAuth/View/Helper/UserConnection.php:50
msgid "Affiche le formulaire d'authentification"
msgstr "Display authentication form"
#: ../src/UnicaenAuth/View/Helper/UserConnection.php:54
msgid "Déconnexion"
msgstr "Logout"
#: ../src/UnicaenAuth/View/Helper/UserConnection.php:55
msgid "Ferme votre session au sein de cette application"
msgstr "Close your application session"
#: ../../../zf-commons/zfc-user/src/ZfcUser/Form/Register.php:36
#: ../view/unicaen-user/user/register.phtml:1
msgid "Register"
msgstr "Register"
#: ../../../zf-commons/zfc-user/src/ZfcUser/Form/Base.php:80
msgid "Submit"
msgstr "Submit"
#: ../view/unicaen-user/user/register.phtml:5
msgid "Registration is disabled"
msgstr "Registration is disabled"
#: ../view/unicaen-user/user/login.phtml:31
msgid "Not registered?"
msgstr "Not registered?"
#: ../view/unicaen-user/user/login.phtml:31
msgid "Sign up!"
msgstr "Sign up!"
#: ../view/unicaen-user/user/index.phtml:2
msgid "Hello,"
msgstr "Hello,"
#~ msgid "Version"
#~ msgstr "Version"
#~ msgid "du"
#~ msgstr "du"
#~ msgid "ou"
#~ msgstr "ou"
#~ msgid "Contact"
#~ msgstr "Contact"
#~ msgid "Contacter par mail"
#~ msgstr "Contacter par mail"
#~ msgid "Inconnu"
#~ msgstr "Inconnu"
#~ msgid "Page d'accueil de l'application"
#~ msgstr "Page d'accueil de l'application"
#~ msgid "Néant"
#~ msgstr "Néant"
#~ msgid "Suivant >"
#~ msgstr "Suivant >"
#~ msgid "Passer à l'étape suivante"
#~ msgstr "Passer à l'étape suivante"
#~ msgid "< Précédent"
#~ msgstr "< Précédent"
#~ msgid "Revenir à l'étape précédente"
#~ msgstr "Revenir à l'étape précédente"
#~ msgid "Annuler"
#~ msgstr "Annuler"
#~ msgid "Abandonner la saisie"
#~ msgstr "Abandonner la saisie"
#~ msgid "Terminer"
#~ msgstr "Terminer"
msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2012-11-23 13:56+0100\n"
"PO-Revision-Date: 2012-11-23 13:56+0100\n"
"Last-Translator: Université de Caen Basse Normandie\n"
"Language-Team: \n"
"Language: \n"
"MIME-Version: 1.0\n"