Skip to content
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

captcha possible for login form #680

Open
wants to merge 12 commits into
base: 3.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace ZfcUser;

use Zend\ModuleManager\Feature\ConfigProviderInterface;
use Zend\ModuleManager\Feature\ControllerPluginProviderInterface;
use Zend\ModuleManager\Feature\ControllerProviderInterface;
use Zend\ModuleManager\Feature\ServiceProviderInterface;
use Laminas\ModuleManager\Feature\ConfigProviderInterface;
use Laminas\ModuleManager\Feature\ControllerPluginProviderInterface;
use Laminas\ModuleManager\Feature\ControllerProviderInterface;
use Laminas\ModuleManager\Feature\ServiceProviderInterface;

class Module implements
ControllerProviderInterface,
Expand Down Expand Up @@ -52,19 +52,19 @@ public function getServiceConfig()
{
return array(
'aliases' => array(
'zfcuser_zend_db_adapter' => \Zend\Db\Adapter\Adapter::class,
'zfcuser_zend_db_adapter' => \Laminas\Db\Adapter\Adapter::class,
),
'invokables' => array(
'zfcuser_register_form_hydrator' => \Zend\Hydrator\ClassMethods::class,
'zfcuser_register_form_hydrator' => \Laminas\Hydrator\ClassMethods::class,
),
'factories' => array(
'zfcuser_redirect_callback' => \ZfcUser\Factory\Controller\RedirectCallbackFactory::class,
'zfcuser_module_options' => \ZfcUser\Factory\Options\ModuleOptions::class,
'ZfcUser\Authentication\Adapter\AdapterChain' => \ZfcUser\Authentication\Adapter\AdapterChainServiceFactory::class,

// We alias this one because it's ZfcUser's instance of
// Zend\Authentication\AuthenticationService. We don't want to
// hog the FQCN service alias for a Zend\* class.
// Laminas\Authentication\AuthenticationService. We don't want to
// hog the FQCN service alias for a Laminas\* class.
'zfcuser_auth_service' => \ZfcUser\Factory\AuthenticationService::class,

'zfcuser_user_hydrator' => \ZfcUser\Factory\UserHydrator::class,
Expand Down
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ Created by Evan Coury and the ZF-Commons team
Introduction
------------

ZfcUser is a user registration and authentication module for Zend Framework 2.
Out of the box, ZfcUser works with Zend\Db, however alternative storage adapter
ZfcUser is a user registration and authentication module for Laminas Framework 2.
Out of the box, ZfcUser works with Laminas\Db, however alternative storage adapter
modules are available (see below). ZfcUser provides the foundations for adding
user authentication and registration to your ZF2 site. It is designed to be very
simple and easy to extend.
Expand All @@ -22,7 +22,7 @@ Versions
--------
Please use below table to figure out what version of ZfcUser you should use.

| ZfcUser version | Supported Zend Framework version | Status |
| ZfcUser version | Supported Laminas Framework version | Status |
|-----------------|----------------------------------|---------------------------------------------|
| 1.x | <= 2.5 | Security-fixes only |
| 2.x | >= 2.6 < 3 | bug-fixes, security-fixes |
Expand All @@ -31,7 +31,7 @@ Please use below table to figure out what version of ZfcUser you should use.
Storage Adapter Modules
-----------------------

By default, ZfcUser ships with support for using Zend\Db for persisting users.
By default, ZfcUser ships with support for using Laminas\Db for persisting users.
However, by installing an optional alternative storage adapter module, you can
take advantage of other methods of persisting users:

Expand All @@ -41,7 +41,7 @@ take advantage of other methods of persisting users:
Requirements
------------

* [Zend Framework 2](https://github.com/zendframework/zf2) (latest master)
* [Laminas Framework](https://github.com/zendframework/zf2) (latest master)
* [ZfcBase](https://github.com/ZF-Commons/ZfcBase) (latest master).

Features / Goals
Expand All @@ -51,7 +51,7 @@ Features / Goals
username and use strictly email) [COMPLETE]
* User registration [COMPLETE]
* Forms protected against CSRF [COMPLETE]
* Out-of-the-box support for Doctrine2 _and_ Zend\Db [COMPLETE]
* Out-of-the-box support for Doctrine2 _and_ Laminas\Db [COMPLETE]
* Robust event system to allow for extending [COMPLETE]
* Provide ActionController plugin and view helper [COMPLETE]

Expand Down Expand Up @@ -107,9 +107,9 @@ Coming soon...

Coming soon...

### Post-Install: Zend\Db
### Post-Install: Laminas\Db

1. If you do not already have a valid Zend\Db\Adapter\Adapter in your service
1. If you do not already have a valid Laminas\Db\Adapter\Adapter in your service
manager configuration, put the following in `./config/autoload/database.local.php`:

```php
Expand All @@ -124,7 +124,7 @@ return array(
),
'service_manager' => array(
'factories' => array(
'Zend\Db\Adapter\Adapter' => 'Zend\Db\Adapter\AdapterServiceFactory',
'Laminas\Db\Adapter\Adapter' => 'Laminas\Db\Adapter\AdapterServiceFactory',
),
),
);
Expand Down Expand Up @@ -183,8 +183,8 @@ The following options are available:
after they successfully register. Default value is `false`.
- **use_registration_form_captcha** - Boolean value, determines if a captcha should
be utilized on the user registration form. Default value is `true`. (Note,
right now this only utilizes a weak Zend\Text\Figlet CAPTCHA, but I have plans
to make all Zend\Captcha adapters work.)
right now this only utilizes a weak Laminas\Text\Figlet CAPTCHA, but I have plans
to make all Laminas\Captcha adapters work.)
- **login_form_timeout** - Integer value, specify the timeout for the CSRF security
field of the login form in seconds. Default value is 300 seconds.
- **user_form_timeout** - Integer value, specify the timeout for the CSRF security
Expand Down Expand Up @@ -226,7 +226,7 @@ module.config.php, or a dedicated recaptcha.config.php):
'instance'=>array(
'alias'=>array(
// OTHER ELEMENTS....
'recaptcha_element' => 'Zend\Form\Element\Captcha',
'recaptcha_element' => 'Laminas\Form\Element\Captcha',
),
'recaptcha_element' => array(
'parameters' => array(
Expand Down
52 changes: 26 additions & 26 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zf-commons/zfc-user",
"description": "A generic user registration and authentication module for ZF2. Supports Zend\\Db and Doctrine2.",
"name": "lampi87/zfc-user",
"description": "A generic user registration and authentication module for ZF2. Supports Laminas\\Db and Doctrine2.",
"type": "library",
"license": "BSD-3-Clause",
"keywords": [
Expand All @@ -25,34 +25,34 @@
}
},
"require": {
"php": "^5.5|^7.0",
"zendframework/zend-authentication": "^2.5",
"zendframework/zend-crypt": "^3.0",
"zendframework/zend-form": "^2.9",
"zendframework/zend-inputfilter": "^2.7",
"zendframework/zend-loader": "^2.5",
"zendframework/zend-modulemanager": "^2.7",
"zendframework/zend-mvc": "^3.0",
"zendframework/zend-servicemanager": "^3.0",
"zendframework/zend-stdlib": "^3.0",
"zendframework/zend-validator": "^2.8",
"zendframework/zend-db": "^2.8",
"zendframework/zend-view": "^2.8",
"zendframework/zend-session" : "^2.7",
"zendframework/zend-http" : "^2.5",
"zendframework/zend-mvc-plugin-flashmessenger": "^1.0",
"zendframework/zend-i18n": "^2.7",
"zendframework/zend-mvc-plugin-prg": "^1.0",
"zendframework/zend-hydrator": "^2.0"
"php": "^7.0",
"laminas/laminas-authentication": "^2.5",
"laminas/laminas-crypt": "^3.0",
"laminas/laminas-form": "^2.9",
"laminas/laminas-inputfilter": "^2.7",
"laminas/laminas-loader": "^2.5",
"laminas/laminas-modulemanager": "^2.7",
"laminas/laminas-mvc": "^3.0",
"laminas/laminas-servicemanager": "^3.0",
"laminas/laminas-stdlib": "^3.0",
"laminas/laminas-validator": "^2.8",
"laminas/laminas-db": "^2.8",
"laminas/laminas-view": "^2.8",
"laminas/laminas-session" : "^2.7",
"laminas/laminas-http" : "^2.5",
"laminas/laminas-mvc-plugin-flashmessenger": "^1.0",
"laminas/laminas-i18n": "^2.7",
"laminas/laminas-mvc-plugin-prg": "^1.0",
"laminas/laminas-hydrator": "^2.0"
},
"require-dev" : {
"phpunit/phpunit" : ">=3.7,<4",
"phpmd/phpmd" : "1.4.*",
"squizlabs/php_codesniffer" : "1.4.*",
"zendframework/zend-captcha" : "^2.6"
"phpunit/phpunit" : "*",
"phpmd/phpmd" : "*",
"squizlabs/php_codesniffer" : "*",
"laminas/laminas-captcha" : "^2.6"
},
"suggest": {
"zendframework/zend-captcha" : "Zend\\Captcha if you want to use the captcha component"
"laminas/laminas-captcha" : "Laminas\\Captcha if you want to use the captcha component"
},
"autoload": {
"psr-0": {
Expand Down
18 changes: 13 additions & 5 deletions config/zfcuser.global.php.dist
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
*/
$settings = array(
/**
* Zend\Db\Adapter\Adapter DI Alias
* Laminas\Db\Adapter\Adapter DI Alias
*
* Please specify the DI alias for the configured Zend\Db\Adapter\Adapter
* Please specify the DI alias for the configured Laminas\Db\Adapter\Adapter
* instance that ZfcUser should use.
*/
//'zend_db_adapter' => 'Zend\Db\Adapter\Adapter',
//'zend_db_adapter' => 'Laminas\Db\Adapter\Adapter',

/**
* User Model Entity Class
Expand Down Expand Up @@ -111,11 +111,19 @@ $settings = array(
*/
//'use_registration_form_captcha' => false,

/**
* Login Form Captcha
*
* Determines if a captcha should be utilized on the user login form.
* Default value is false.
*/
//'use_login_form_captcha' => false,

/**
* Form Captcha Options
*
* Currently used for the registration form, but re-usable anywhere. Use
* this to configure which Zend\Captcha adapter to use, and the options to
* this to configure which Laminas\Captcha adapter to use, and the options to
* pass to it. The default uses the Figlet captcha.
*/
/*'form_captcha_options' => array(
Expand Down Expand Up @@ -229,7 +237,7 @@ return array(
'zfcuser' => $settings,
'service_manager' => array(
'aliases' => array(
'zfcuser_zend_db_adapter' => (isset($settings['zend_db_adapter'])) ? $settings['zend_db_adapter']: 'Zend\Db\Adapter\Adapter',
'zfcuser_zend_db_adapter' => (isset($settings['zend_db_adapter'])) ? $settings['zend_db_adapter']: 'Laminas\Db\Adapter\Adapter',
),
),
);
4 changes: 2 additions & 2 deletions src/ZfcUser/Authentication/Adapter/AbstractAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace ZfcUser\Authentication\Adapter;

use Zend\Authentication\Storage;
use Laminas\Authentication\Storage;

abstract class AbstractAdapter implements ChainableAdapter
{
Expand All @@ -21,7 +21,7 @@ abstract class AbstractAdapter implements ChainableAdapter
public function getStorage()
{
if (null === $this->storage) {
$this->setStorage(new Storage\Session(get_class($this)));
$this->setStorage(new Storage\Session('ZfcUser'));
}

return $this->storage;
Expand Down
14 changes: 7 additions & 7 deletions src/ZfcUser/Authentication/Adapter/AdapterChain.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

namespace ZfcUser\Authentication\Adapter;

use Zend\Authentication\Adapter\AdapterInterface;
use Zend\Authentication\Result as AuthenticationResult;
use Zend\EventManager\Event;
use Zend\EventManager\EventInterface;
use Zend\EventManager\EventManagerAwareTrait;
use Zend\Stdlib\RequestInterface as Request;
use Zend\Stdlib\ResponseInterface as Response;
use Laminas\Authentication\Adapter\AdapterInterface;
use Laminas\Authentication\Result as AuthenticationResult;
use Laminas\EventManager\Event;
use Laminas\EventManager\EventInterface;
use Laminas\EventManager\EventManagerAwareTrait;
use Laminas\Stdlib\RequestInterface as Request;
use Laminas\Stdlib\ResponseInterface as Response;
use ZfcUser\Exception;

class AdapterChain implements AdapterInterface
Expand Down
4 changes: 2 additions & 2 deletions src/ZfcUser/Authentication/Adapter/AdapterChainEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace ZfcUser\Authentication\Adapter;

use Zend\EventManager\Event;
use Zend\Stdlib\RequestInterface as Request;
use Laminas\EventManager\Event;
use Laminas\Stdlib\RequestInterface as Request;

class AdapterChainEvent extends Event
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

use Interop\Container\ContainerInterface;
use Interop\Container\Exception\ContainerException;
use Zend\ServiceManager\Exception\ServiceNotCreatedException;
use Zend\ServiceManager\Exception\ServiceNotFoundException;
use Zend\ServiceManager\Factory\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
use Laminas\ServiceManager\Exception\ServiceNotCreatedException;
use Laminas\ServiceManager\Exception\ServiceNotFoundException;
use Laminas\ServiceManager\Factory\FactoryInterface;
use Laminas\ServiceManager\ServiceLocatorInterface;
use ZfcUser\Authentication\Adapter\AdapterChain;
use ZfcUser\Options\ModuleOptions;
use ZfcUser\Authentication\Adapter\Exception\OptionsNotFoundException;
Expand Down
4 changes: 2 additions & 2 deletions src/ZfcUser/Authentication/Adapter/ChainableAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace ZfcUser\Authentication\Adapter;

use Zend\Authentication\Storage\StorageInterface;
use Zend\EventManager\EventInterface;
use Laminas\Authentication\Storage\StorageInterface;
use Laminas\EventManager\EventInterface;

interface ChainableAdapter
{
Expand Down
12 changes: 6 additions & 6 deletions src/ZfcUser/Authentication/Adapter/Db.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
namespace ZfcUser\Authentication\Adapter;

use Interop\Container\ContainerInterface;
use Zend\Authentication\Result as AuthenticationResult;
use Zend\EventManager\EventInterface;
use Zend\ServiceManager\ServiceManager;
use Zend\Crypt\Password\Bcrypt;
use Zend\Session\Container as SessionContainer;
use Laminas\Authentication\Result as AuthenticationResult;
use Laminas\EventManager\EventInterface;
use Laminas\ServiceManager\ServiceManager;
use Laminas\Crypt\Password\Bcrypt;
use Laminas\Session\Container as SessionContainer;
use ZfcUser\Entity\UserInterface;
use ZfcUser\Mapper\UserInterface as UserMapperInterface;
use ZfcUser\Options\ModuleOptions;
Expand Down Expand Up @@ -105,7 +105,7 @@ public function authenticate(AdapterChainEvent $e)
}

// regen the id
$session = new SessionContainer($this->getStorage()->getNameSpace());
$session = new SessionContainer('ZfcUser');
$session->getManager()->regenerateId();

// Success!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace ZfcUser\Authentication\Adapter\Exception;

use Zend\Math\Exception\RuntimeException;
use Laminas\Math\Exception\RuntimeException;

class OptionsNotFoundException extends RuntimeException
{
Expand Down
Loading