Commit 278c4292 authored by Stephane Bouvry's avatar Stephane Bouvry
Browse files

DOC

Test sur les événements de connexion
parent 9ce49acd
Loading
Loading
Loading
Loading
Loading
+74 −0
Original line number Diff line number Diff line
# MACCLANE : Patch LDAP
## 6 mai 2021

Ce patch introduit un FIX/Up sur la partie authentification de Oscar. 
Il simplifie la configuration d'authentification multiple 
 - CAS
 - LDAP / Local(Base de données)
 - Shibboleth

Ce patch résout également certains problème d'authentification liè au rôles LDAP.

La mise en place de ce patch implique des changements sur la configuration de l'authentification. Voici le **contenu minimal** attendu dans le fichier `config/autoload/unicaen-auth.local.php`

> **Important** : Toutes les clefs doivent être présentent dans le fichier, même si la méthode de connexion n'est pas utilisée. Pour activer/désactiver une méthode de configuration, modifiez simplement la valeur `enable` sur `true/false` selon les besoins.

```php
<?php
// ./config/autoload/unicaen-auth.local.php
$settings = array(
    // LDAP / DB
    'local' => [
        'order' => 2,
        'enabled' => true,
        'db' => [
            'enabled' => true,
        ],
        'ldap' => [
            'enabled' => true,
        ],
    ],

     // Authentification via la fédération d'identité (Shibboleth).
    'shib' => [
        'order' => 4,
        'enabled' => false,
        'logout_url' => '/Shibboleth.sso/Logout?return=', // NB: '?return=' semble obligatoire!
        'aliases' => [
            'eppn'                   => 'HTTP_EPPN',
            'mail'                   => 'HTTP_MAIL',
            'eduPersonPrincipalName' => 'HTTP_EPPN',
            'supannEtuId'            => 'HTTP_SUPANNETUID',
            'supannEmpId'            => 'HTTP_SUPANNEMPID',
            'supannCivilite'         => 'HTTP_SUPANNCIVILITE',
            'displayName'            => 'HTTP_DISPLAYNAME',
            'sn'                     => 'HTTP_SN',
            'givenName'              => 'HTTP_GIVENNAME',
        ],
    ],
    
    // CAS
    'cas' => [
        'order' => 1,
        'enabled' => false,
        'connection' => [
            'default' => [
                'params' => [
                    'hostname' => 'host.domain.fr',
                    'port'     => 443,
                    'version'  => "2.0",
                    'uri'      => "",
                    'debug'    => false,
                ],
            ],
        ]
    ],
);

/**
 * You do not need to edit below this line
 */
return array(
    'unicaen-auth' => $settings,
);
```
 No newline at end of file
+22 −25
Original line number Diff line number Diff line
@@ -9,34 +9,10 @@

namespace Oscar;

use Doctrine\ORM\EntityManager;
use Doctrine\ORM\NonUniqueResultException;
use Doctrine\ORM\NoResultException;
use Monolog\Logger;
use Oscar\Auth\UserAuthenticatedEventListener;
use Oscar\Entity\LogActivity;
use Oscar\Entity\ActivityLogRepository;
use Oscar\Entity\Authentification;
use Oscar\Exception\OscarException;
use Oscar\Service\ActivityLogService;
use Oscar\Service\OscarUserContext;
use Oscar\Service\PersonService;
use UnicaenAuth\Authentication\Adapter\Ldap;
use UnicaenAuth\Event\UserAuthenticatedEvent;
use UnicaenAuth\Provider\Identity\ChainEvent;
use UnicaenAuth\Service\User;
use UnicaenAuth\Service\UserContext;
use Zend\Console\Adapter\AdapterInterface;
use Zend\EventManager\Event;
use Zend\Http\PhpEnvironment\Request;
use Zend\ModuleManager\Feature\ConsoleBannerProviderInterface;
use Zend\ModuleManager\Feature\ConsoleUsageProviderInterface;
use Zend\ModuleManager\ModuleEvent;
use Zend\Authentication\Result as AuthenticationResult;
use Zend\ModuleManager\ModuleManager;
use Zend\Mvc\ModuleRouteListener;
use Zend\Mvc\MvcEvent;
use Zend\Mvc\Router\Http\RouteMatch;
use Zend\ServiceManager\ServiceManager;
use ZfcUser\Authentication\Adapter\AdapterChainEvent;

class Module
@@ -45,7 +21,28 @@ class Module

    public function onBootstrap(MvcEvent $e)
    {
        // TODO a tester
        $e->getApplication()->getEventManager()->getSharedManager()->attach(
            "*",
            'authenticate', //"authentication.success",
                    [$this, "onUserLogin"],
                100
        );
    }

    public function onUserLogin( $e ) {
        die("onUserLogin");

//        if (is_string(\$identity = \$e->getIdentity())) {
//            // login de l'utilisateur authentifié
//            \$username = \$identity;
//            //...
//        } else {
//            // id de l'utilisateur authentifié dans la table
//            \$id = \$identity;
//            //...
//        }
      //...
}

    // FIX : ZendFramework 3
+6 −0
Original line number Diff line number Diff line
@@ -23,6 +23,12 @@ return array(
                    'roles' => [],
                ],

                [
                    'controller' => '\UnicaenAuth\Controller\Utilisateur',
                    'action' => ['usurperIdentite'],
                    'roles' => []
                ],

                [ 'controller' =>  'Public',
                    'action' => ['documentation', 'parameters', 'gitlog'],
                    'roles' => ['user'],
+10 −0
Original line number Diff line number Diff line
@@ -5499,3 +5499,13 @@ pre.alert-danger, pre.alert-info {
.datepicker-selector .week .week-day:nth-child(odd) {
  background: rgba(0, 0, 0, 0.05);
}

// UNICAEN
.div-connexion {
  max-width: 600px;
  margin: 0 auto;
}

.connect-credentials-lost {
  display: none;
}
 No newline at end of file
+9 −0
Original line number Diff line number Diff line
@@ -11677,6 +11677,15 @@ pre.alert-danger, pre.alert-info {
  background: rgba(0, 0, 0, 0.05);
}

.div-connexion {
  max-width: 600px;
  margin: 0 auto;
}

.connect-credentials-lost {
  display: none;
}

body {
  background: #f2f3eb;
}
Loading