Commit 0b0d087e authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

Teste la source de l'authentification réalisée pour bien aller chercher les...

Teste la source de l'authentification réalisée pour bien aller chercher les infos utilisateur dans la table oauth_users le cas échéant et pas dans l'annuaire LDAP !
parent c0af4fb0
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
@@ -24,6 +24,8 @@ class StorageAdapter extends PdoAdapter

    const PASSWORD_CAS_PREFIX = "cas_";

    private $sourceOfAuthentification; // 'db', 'ldap' ou 'cas'

    /**
     * Redéfinition.
     *
@@ -37,6 +39,7 @@ class StorageAdapter extends PdoAdapter
    public function checkUserCredentials($username, $password)
    {
        if ($user = parent::getUser($username)) {
            $this->sourceOfAuthentification = 'db';
            return parent::checkPassword($user, $password);
        }

@@ -77,6 +80,8 @@ class StorageAdapter extends PdoAdapter

    private function checkLdapAuthentication($user, $password)
    {
        $this->sourceOfAuthentification = 'ldap';

        $ldapAuthAdapter = $this->getLdapAuthAdapter();
        $ldapAuthAdapter
            ->setUsername($user['dn'])
@@ -88,6 +93,8 @@ class StorageAdapter extends PdoAdapter

    private function checkCasAuthentication()
    {
        $this->sourceOfAuthentification = 'cas';

        return $this->getServiceCas()->checkAuthentication();
    }

@@ -136,6 +143,23 @@ class StorageAdapter extends PdoAdapter
        throw new \BadMethodCallException("Méthode à implémenter !");
    }

    /**
     * Redéfinition.
     *
     * Teste la source de l'authentification réalisée pour bien aller chercher les infos utilisateur
     * dans la table "oauth_users" le cas échéant et pas dans l'annuaire LDAP !
     *
     * @param string $username
     * @return array|bool
     */
    public function getUserDetails($username)
    {
        if ($this->sourceOfAuthentification === 'db') {
            return parent::getUser($username);
        }
        return $this->getUser($username);
    }

    /**
     * @var PeopleLdapService
     */