-
Notifications
You must be signed in to change notification settings - Fork 6
Add a Dummy authentication driver #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
lib/Horde/Auth/Dummy.php
Outdated
| * @license http://www.horde.org/licenses/lgpl21 LGPL-2.1 | ||
| * @package Auth | ||
| */ | ||
| class Horde_Auth_Dummy extends Horde_Auth_Base |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
lib/Horde/Auth/Dummy.php
Outdated
| @@ -0,0 +1,171 @@ | |||
| <?php | |||
| /** | |||
| * Copyright 2017-2018 Horde LLC (http://www.horde.org/) | |||
There was a problem hiding this comment.
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 ;-)
lib/Horde/Auth/Dummy.php
Outdated
| throw new Horde_Auth_Exception('User already exists'); | ||
| } | ||
| $this->_params['users'][$userId] = Horde_Auth::getCryptedPassword( | ||
| $credentials['password'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix indention
lib/Horde/Auth/Dummy.php
Outdated
| * @param boolean $sort Sort the users? | ||
| * | ||
| * @return mixed The array of userIds. | ||
| * @throws Horde_Auth_Exception |
There was a problem hiding this comment.
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.
lib/Horde/Auth/Dummy.php
Outdated
| */ | ||
| protected function _authenticate($userId, $credentials) | ||
| { | ||
| if ($this->exists($userId)) { |
There was a problem hiding this comment.
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
lib/Horde/Auth/Dummy.php
Outdated
| */ | ||
| protected function _comparePasswords($encrypted, $plaintext) | ||
| { | ||
| return $encrypted == Horde_Auth::getCryptedPassword($plaintext, |
There was a problem hiding this comment.
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 | |||
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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.
|
And please rebase on current master to fix the travis 5.6 and 7.0 builds |
Remove unnecessary comment line
|
Closing this for new, clean #2 |
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.