Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

Login with Mail Address and LDAP fallback #31

@mano87

Description

@mano87

Hello,
for internal user authentication we will use LDAP Adapter and for external users the Zend DB Adapter. All external users uses the mail address as username. Also with the LDAP Adapter we will use the email address as username. We have more external than internal users.

  1. How could the login login scheme look like?
  2. LDAP as Fallback Adapter?
  3. But how can we make sense that the LDAP also uses the mail address for the login? (first LDAP search and then bind with dn?)
class AuthenticationService extends ZendAuthenticationService implements AuthenticationServiceInterface
{
    /**
     * Authentication fallback adapter
     *
     * @var AdapterInterface
     */
    private $fallbackAdapter = null;

    /**
     * @param AdapterInterface $adapter
     * @return $this
     */
    public function setFallbackAdapter(AdapterInterface $adapter)
    {
        $this->fallbackAdapter = $adapter;
        return $this;
    }

    /**
     * @return AdapterInterface
     */
    public function getFallbackAdapter()
    {
        return $this->fallbackAdapter;
    }

    /**
     * @param AdapterInterface|null $fallbackAdapter
     * @return Result
     */
    public function fallbackAuthenticate(AdapterInterface $fallbackAdapter = null)
    {
        if (!$fallbackAdapter) {
            $fallbackAdapter = $this->getFallbackAdapter();
        }

        return $fallbackAdapter->authenticate();
    }

    /**
     * @return mixed
     */
    public function getIdentity()
    {
        if ($this->hasIdentity()) {
            $user = parent::getIdentity();
        } else {
            $user = new UserEntity();
            $user->setId(0);
            $user->setUsername('Gast');
            $user->setRole('guest');
        }

        return $user;
    }

}

@heiglandreas

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions