Skip to content

Conversation

@ralflang
Copy link
Member

The Dummy authentication driver allows to password protect a horde installation with a fixed set of login credentials.
It is fast for a small amount of users as it keeps everything in memory and is easy to set up.
This makes it useful for stripped down installations like demo setups, API providers, no DB setups, integration tests etc.

Different from the Auto driver, it actually requires the user to login.

The driver provides actual functionality to add, remove or update users and keep changes, though it is pointless. Without actually changing the driver configuration, the driver will forget any changes with the next request.

Out of scope of this individual PR:
Provide Core and base integration
Provide a callback mechanism and a sample callback to persist any changes.

* @license http://www.horde.org/licenses/lgpl21 LGPL-2.1
* @package Auth
*/
class Horde_Auth_Dummy extends Horde_Auth_Base
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is rather a Mock driver, it should be called like that.


/**
* The Horde_Auth_Dummy class provides an in-memory user list.
* It is meant to be used for throwaway setups, satellite systems or for
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One empty line here to separate description from summery

@@ -0,0 +1,171 @@
<?php
/**
* Copyright 2017-2018 Horde LLC (http://www.horde.org/)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not 2018 yet ;-)

throw new Horde_Auth_Exception('User already exists');
}
$this->_params['users'][$userId] = Horde_Auth::getCryptedPassword(
$credentials['password'],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix indention

* @param boolean $sort Sort the users?
*
* @return mixed The array of userIds.
* @throws Horde_Auth_Exception
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't throw an exception. Some other methods don't either.

*/
protected function _authenticate($userId, $credentials)
{
if ($this->exists($userId)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is easier to follow by negating the check, i.e. if (!$this->exists || $this->_compare) throw

*/
protected function _comparePasswords($encrypted, $plaintext)
{
return $encrypted == Horde_Auth::getCryptedPassword($plaintext,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentions. Wrap the first argument already, then line-up further arguments.

@@ -0,0 +1,143 @@
<?php
/**
* PHP version 5
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary line

$this->driver->addUser('user4', array('password' => 'foo'));
$this->assertCount(4, $this->driver->listUsers());
// Add somebody who already exist
$this->setExpectedException(Horde_Auth_Exception::class);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

::class makes travis fail on php 5.4.

@yunosh
Copy link
Member

yunosh commented Oct 27, 2017

And please rebase on current master to fix the travis 5.6 and 7.0 builds

@ralflang
Copy link
Member Author

Closing this for new, clean #2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants