Closed
Conversation
yunosh
requested changes
Oct 27, 2017
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 |
Member
There was a problem hiding this comment.
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 |
Member
There was a problem hiding this comment.
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/) | |||
lib/Horde/Auth/Dummy.php
Outdated
| throw new Horde_Auth_Exception('User already exists'); | ||
| } | ||
| $this->_params['users'][$userId] = Horde_Auth::getCryptedPassword( | ||
| $credentials['password'], |
lib/Horde/Auth/Dummy.php
Outdated
| * @param boolean $sort Sort the users? | ||
| * | ||
| * @return mixed The array of userIds. | ||
| * @throws Horde_Auth_Exception |
Member
There was a problem hiding this comment.
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)) { |
Member
There was a problem hiding this comment.
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, |
Member
There was a problem hiding this comment.
Indentions. Wrap the first argument already, then line-up further arguments.
| @@ -0,0 +1,143 @@ | |||
| <?php | |||
| /** | |||
| * PHP version 5 | |||
| $this->driver->addUser('user4', array('password' => 'foo')); | ||
| $this->assertCount(4, $this->driver->listUsers()); | ||
| // Add somebody who already exist | ||
| $this->setExpectedException(Horde_Auth_Exception::class); |
Member
There was a problem hiding this comment.
::class makes travis fail on php 5.4.
Member
|
And please rebase on current master to fix the travis 5.6 and 7.0 builds |
Remove unnecessary comment line
Member
Author
|
Closing this for new, clean #2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.