Coder Social home page Coder Social logo

zf-commons / zfcuser Goto Github PK

View Code? Open in Web Editor NEW
499.0 499.0 347.0 1.09 MB

A generic user registration and authentication module for ZF2. Supports Zend\Db and Doctrine2. (Formerly EdpUser)

License: BSD 3-Clause "New" or "Revised" License

PHP 98.97% HTML 1.03%

zfcuser's Introduction

ZF-Commons

Placeholder repository for Wiki information on members, policities, and RFC's.

zfcuser's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

zfcuser's Issues

Password already crypted with different salt in production

Hi there i'd like to use BCrypt to authenticate/register my users.

But in production my user passwords are already crypted like this:

$cost = 10;
$key = 'flipperCasimodoProsper'; # 22 base64 digits
$salt = '$2a$' . $cost . '$' . $key;

I want want be able to use
Zend\Crypt\Password\Bcrypt::create($password) :
$salt64 = substr(str_replace('+', '.', base64_encode($salt)), 0, 22);

i tried : $bcrypt->setSalt ( str_replace(' ','+',base64_decode('flipperCasimodoProsper')) );

but $bcrypt->getSalt() => 'flipperCasimodoProspeg' <> $key ( 'flipperCasimodoProsper')

So i don't know what to do!

Can anyone help me ?

Not able to login with username

When loging in with username module does (ZfcUser/src/ZfcUser/Authentication/Storage/Db.php->authenticate()):

  1. Try to select row with email which equals to identity field (ZfcUser/src/ZfcUser/Model/UserMapper.php->findByEmail()).
  2. If #1 faults it try to select the row with username equivalent to identity field. But it doesn't clear old select predictions so the both conditions will be used at once. It looks like WHERE email = "identity" AND username = "identity" (ZfcUser/src/ZfcUser/Model/UserMapper.php->findByUsername()).

I didn't found a good way to clear select predictions. The only way i found is:
$select = new \Zend\Db\Sql\Select();
$this->getTableGateway()->setSqlSelect($select);

May be it is better to use one request with "or" instead of two requests and ugly hack.

Tested with ZF 2.0.0beta3.

Adding fields to User entity

Hi,

is there a part of documentation which describes how to add fields to the User entity (for example first_name / last_name)?

I'm new to Zend and it doesn't really seem obvious to me at this point.

Zend\Db\Adapter\Exception\InvalidQueryException on Register

register user and zfcUser throw an exception 'Zend\Db\Adapter\Exception\InvalidQueryException'
Message:
Data truncated for column 'last_ip' at row 1

Reason:
in UserMapper Class persists method called $user->toArray()

        $data = new ArrayObject($user->toArray());

and in ModelAbstract toArray() invoke getter method to return data
but those method return a string instean of long int with default param:

    public function getLastIp($long = false)
    public function getRegisterIp($long = false)

ZfcUser\Mapper\User Configurable

Make the Mapper configurable in the Config File like user_entity_class

Would be a great enhancement for Modifying the Database-Selects (Last Login, First Login, and so on)

Order of modules affects ZfcUser route matching

Putting ZfcUser ahead of an application module implementing the default and home routes from the skeleton app causes /user route to not work. Moving ZfcUser after the other routing module fixed the issue.

Remove dependency on ZendFramework from composer

This module has a dependency to ZfcBase which allready resolves the Zendframework dependency. I think it would be a good idea to remove it from composer which would then release us from updating composer each time zf has a new release

Possible case mismatch between forms and user service.

Login form and register form are currently expecting camel case as shown below:

if (!$this->getRegistrationOptions()->getEnableDisplayName()) {
    $this->remove('displayName');
}

User service is expecting underscore:

if ($this->getOptions()->getEnableDisplayName()) {
    $user->setDisplayName($data['display_name']);
}

Unsure if there are other cases in the module.

Controller Plugins not registering through DI

This section of the config doesn't work:

        'Zend\Mvc\Controller\PluginLoader' => array(
            'parameters' => array(
                'map' => array(
                    'zfcUserAuthentication' => 'ZfcUser\Controller\Plugin\ZfcUserAuthentication',
                ),
            ),
        ),

The plugins defined in
Zend\Mvc\Controller\PluginLoader
are listed but the constructor with the map is not instantiated.

The exception is: Message: Unable to locate class associated with "zfcuserauthentication"
and I can't get by the controller index action to use the module.

I hope this is just an issue I've created but I cannot find a reason this doesn't work.

Tom

Dates entered into the database in the wrong format - insert fails

ZfcUser fails to enter dates in the database because for some reason the format set in ZfcUser results in the following format:

2012-04-27T02:27:11+01:00

MySQL doesn't like this format.

(P.S. Just raised a couple of issues so to balance that, I do think this looks like a very promising module - and thanks to the devs responsible for creating it. Any pointers as to what's going wrong would be great!)

Fatal errors with ZfcUser\Model\Use and ZfcUser\Authentication\Adapter\AdapterChainEvent

I just pulled the newest master of zf2 and now I get two new errors.

First:
Fatal error: Class ZfcUser\Model\User contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (Zend\Db\ResultSet\RowObjectInterface::populate) ...

Well obviously the ZfcUser\Model\User class does not implement a "populate" method and that causes the error.

Second:
Catchable fatal error: Argument 1 passed to ZfcUser\Authentication\Adapter\AdapterChainEvent::setRequest() must be an instance of Zend\Stdlib\RequestDescription, instance of Zend\Http\PhpEnvironment\Request given ...

If fixed this by replacing
Zend\Stdlib\RequestDescription as Request;
with
Zend\Stdlib\RequestInterface as Request;

I tried making a fresh clone with of zf2 and ZfcUser to see if I somehow screwed it up myself, but the problem remains.

How to use it?

Hi, I've installed ZfcUser now what?
How do I know if it works?
Any tutorials?

What I need is to password protect my zend framework site.
So if user is not logged in it should be redirected to login page, otherwise user should see requested page.

Unable to locate class associated with "zfcuserauthentication"

I setup the latest version (2012-05-20) of zendframework / ZendSkeletonApplication, ZF-Commons / ZfcBase and ZF-Commons / ZfcUser.

But when I access /user route, I get the error:
Unable to locate class associated with "zfcuserauthentication"

Couldn't find answer and I already went through the instructions and configuration files if I had any mistakes there.

br, Marko

TableName error.

I followed the instructions twice. I updated all and there is no way to make this function. Three hours debuging without a clue.

Some help will be appreciated

Fatal error: Uncaught exception 'Zend\Di\Exception\MissingPropertyException' with message 'Missing instance/object for parameter tableName for Zend\Db\TableGateway\TableGateway::__construct' in /www_sites/zendf2/vendor/ZendFramework/library/Zend/Di/Di.php:617 Stack trace: #0 /www_sites/zendf2/vendor/ZendFramework/library/Zend/Di/Di.php(324): Zend\Di\Di->resolveMethodParameters('Zend\Db\TableGa...', '__construct', Array, true, 'zfcuser_user_tg', true) #1 /www_sites/zendf2/vendor/ZendFramework/library/Zend/Di/Di.php(178): Zend\Di\Di->createInstanceViaConstructor('Zend\Db\TableGa...', Array, 'zfcuser_user_tg') #2 /www_sites/zendf2/vendor/ZendFramework/library/Zend/Di/Di.php(130): Zend\Di\Di->newInstance('zfcuser_user_tg', Array) #3 /www_sites/zendf2/vendor/ZendFramework/library/Zend/Di/Di.php(607): Zend\Di\Di->get('zfcuser_user_tg', Array) #4 /www_sites/zendf2/vendor/ZendFramework/library/Zend/Di/Di.php(324): Zend\Di\Di->resolveMethodParameters('ZfcUser\Model\U...', '__construct', Array, true, 'zfcuser_user_ma...', true) #5 in /www_sites/zendf2/vendor/ZendFramework/library/Zend/Di/Di.php on line 617

A target service or target alias could not be located

  • Fresh clone of ZendSkeletonApplication and installed using Composer (today, 24th May, 2012)
    -- http://myproject shows Zend Skeleton Application welcome page normally.
  • Fresh clone of ZfcUser and ZfcBase into vendor/
  • Added 'ZfcUser' and 'ZfcBase' into 'modules' array in application.config.php
  • copied module.zfcuser.config.php into ./config/autoload/
  • added database.config.php to ./config/autoload/
  • Edited line 15 of ./configs/autoload/module.zfcuser.config.php
    -- Tried both 'zend_db_adapter' => 'masterdb', (as per current instructions on github) and 'zend_db_adapter' => 'Zend\Db\Adapter\Adapter', (as per comments from issue #42)

Now I get a ServiceNotFoundException - seems like it has to do with Zend\ServiceManager\ServiceManager->setAlias('zfcuser_zend_db...', 'Zend\Db\Adapter...') but for the life of me, I can't figure it out.

Have I done something wrong?

InputFilters should also trigger events

If you can add form elements to the form, you should be able to validate/filter those elements with the input filter for that element. So analogous to the init event of a form, I would be glad to have an init for the appropriate input filters.

ServiceManagerAwareInterface initializer removed in zf2-develop

Hello!
in develop an initializer for action controller (plugins) is removed. Therefore zfcUser does not work anymore...

I'm sorry but I don't see the obvious thing to do here... Could someone please... I'll PR it if neccesary

class ZfcUserAuthentication extends AbstractPlugin implements ServiceManagerAwareInterface
{

    ...

    /**
     * Retrieve service manager instance
     *
     * @return ServiceManager
     */
    public function getServiceManager()
    {
        return $this->serviceManager->getServiceLocator();
    }

    /**
     * Set service manager instance
     *
     * @param ServiceManager $locator
     * @return void
     */
    public function setServiceManager(ServiceManager $serviceManager)
    {
        $this->serviceManager = $serviceManager;
    }

basz:On investigation it might be zf2 dev-develop…
[11:42pm]basz:a controller plugin from zfcuser uses ServiceManagerAwareInterface, but setServiceManager isn't called
[11:42pm]basz:I think it should?
[11:42pm]weierophinney:basz: ah -- yeah, that initializer is removed in develop
[11:43pm]basz:aha… thats is a good idea…
[11:43pm]weierophinney:basz: basically, we're trying to reduce confusion, and get people using get/setServiceLocator instead (we'd done this in all but one place in the framework, and that one place was the Application object itself)
[11:44pm]basz:So it should implement ServiceLocatorAwareInterface
[11:44pm]weierophinney:basz: so, the appropriate way forward, and one that will remain forward compatible, is to change over to ServiceLocatorAwareInterface, and to then do an instanceof check inside the method if you need specific features of the ServiceManager.

Unable to locate zfcuserauthentication plugin

I get the following exception message on a vanilla install of ZfcUser:

Unable to locate class associated with "zfcuserauthentication"

Dumping DI initially indicated that Zend\Mvc\Controller\PluginBroker was not being injected with the configured PluginLoader; however adding a DI entry for the former class with a "loader" parameter pointing to PluginLoader did nothing to change the message.

This is using rev b95fca2 of ZF2, rev 2e65b5c of ZfcUser, and rev 796bb6c of ZfcBase.

Not working when installed with composer

When I cloned it manually from git to vendor folder - it's working fine, but when I installed it with composer:

{
"name": "zendframework/skeleton-application",
"description": "Skeleton Application for ZF2",
"license": "BSD-3-Clause",
"keywords": [
    "framework",
    "zf2"
],
"homepage": "http://framework.zend.com/",
"minimum-stability": "dev",
"require": {
    "php": ">=5.3.3",
    "zendframework/zendframework": "2.*",
    "zf-commons/zfc-user" : "dev-master",
    "cdli/CdliTwoStageSignup" : "dev-master"
}
}

and added to autoloader:

 'modules' => array(
     'Application',
     'ZfcBase',
     'ZfcUser',
 ),

I cannot see "/user" page - it's giving 404!

The only difference with composer - it's installing it in /vendor/zf-commons/zfc-user folder instead of /vendor/ZfcUser as git clone doing.

What can be the problem? Routing?

Multiple per-login database updates

Currently there are potentially two UPDATE statements happening on successful login.. first to update last login and last IP, and a second to update the password hash if the hashing strategy has changed since last login. This could be consolidated into one update query.

Mongo Support

Hi guys I am implementing ODM into Zf2, I have it working nicely now with tests but would love to implement this module with ODM support and 3rd party oauth logins. Any ideas of the progress, I tried to finish what is done myself but it seems the DI will cause errors if the PDO configs are missing. Just want to have ODM stuff loaded. Let me know of the progress and if help is required.

PostgreSQL support

Changing how the user_id is stored, in postgreSQL using the equivalent to auto increment causes a not Null exception and will not save the record from registration form. I am trying to find go thru the code and find out how to fix this and post it back here. Also trying to add UUID support for the user_id as an option as this would support a more robust user_id numbering system I would think.

Events with select object attached

findById() and other relevant methods in the mapper should trigger an event with the select object in it before it executes the query. This would allow a listener to alter the select object to, for example, join with another table.

PHP Fatal error: Class ZfcUser\Module contains 1 abstract method and must therefore be declared abstract

Hello there,

I installed the module on ZF2 beta5 + the ZF2 skeleton, I'm using sqlite.
When I'm going to /user I'm getting the following error message:

PHP Fatal error: Class ZfcUser\Module contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (Zend\ModuleManager\Feature\ServiceProviderInterface::getServiceConfiguration) in C:\xxx\trunk\vendor\ZfcUser\src\ZfcUser\Module.php on line 130

Thanks!

Catching the init event is broken

Hi,

i searched a solution which can add form elements to the basic ZfcUser Form without changing the ZfcUser Module code. I found a way like this: http://juriansluiman.nl/nl/article/117/use-3rd-party-modules-in-zend-framework-2

But with latest ZF2 there seems to be some changes, so I debugged and changed the partial code of my Module.php to:

    public function onBootstrap(EventInterface $e)
    {
        /**
         * @var \Zend\Mvc\Application
         */
        $app = $e->getApplication();
        $eventManager = $app->getEventManager();
        $em = $eventManager->getSharedManager();

        $em->attach('ZfcUser\Form\Register', 'init', function($e) {
            // $form is a ZfcUser\Form\Register
            $form = $e->getTarget();
            $form->add(array(
                'name' => 'accept',
                'attributes' => array(
                    'label' => 'Accept Terms of Use',
                    'type' => 'checkbox'
                ),
            ));
        });
    }

The onBootstrap works, but the closure is never called. Jurian, who wrote the article, has confirmed my issue. I tried a lot of things, but i found no solution for it, for now.

Best regards,
Nico

Error with ZF2 RC5

Fatal error: Uncaught exception 'Zend\Form\Exception\DomainException' with message 'Zend\Form\View\Helper\FormButton::render expects either button content as the second argument, or that the element provided has a label value; neither found.

passwd in not a legal key for Pdo connection string

There is a mistake in the Zend\Db post-install instruction:

    'masterdb' => array(
        'parameters' => array(
            'dsn'            => "mysql:dbname={$mdb['dbname']};host={$mdb['host']}",
            'username'       => $mdb['user'],
            'passwd'         => $mdb['pass'],
            'driver_options' => array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'UTF8\''),
        ),
    ),

passwd is not a legal key, it has to either be pass or password.

Support for storing IPv6 addresses

ZfcUser is currently using ip2long() to store IP's in the database; however this only works with IPv4. (We don't want to use MySQL's INET_ATON/NTOA methods, as that is MySQL-specific and ZfcUser is not).

ZfcUser will not authenticate / login a user

I'm having issues with users being unable to login. My knowledge of ZF2 events is poor, so what I'm about to say may be a red herring, but...

Through a bit of playing around, I'm getting the feeling that the Db Adapter's authenticate method is intended to be called through an "authenticate" event. This is assigned in setDefaultAdapter but subsequently lost and so never gets called. I haven't tracked down why / where it gets lost yet, but the result is that it does not get called and the user is not logged in.

Installation fails

I do the following:

  • recursive clone of zend skelton app which includes zf2
  • clone of ZfcBase into vendor
  • clone of ZfcUser into vendor
  • setup the db schema
  • add the provided database.config.php to the config autoload folder
  • copy/paste the module.zfcuser.config.php to the autoloader folder and set the alias (masterdb)
  • go to domain/user

I get this error:

Catchable fatal error: Argument 2 passed to Zend\Db\TableGateway\TableGateway::__construct() must be an instance of Zend\Db\Adapter\Adapter, instance of PDO given in C:\htdocs\zf2-skeleton\vendor\ZendFramework\library\Zend\Db\TableGateway\TableGateway.php on line 100

Custom password generator

Actually there is a static dependency to bcrypt. I have some old intranet applications that need md5-hashed passwords (not optimal, I know, but I cannot change for the moment), so I have to extend ZfcUser\Authentication\Adapter\Db and ZfcUser\Service\User on various positions.

There is one position, Zend\Crypt\Password\Bcrypt could not be replaced against any other class implementing Zend\Crypt\Password\PasswordInterface, but I don't understand it that well so I could say, whether there might be a solution to make it more customizable and if it is wanted though.

Steps for implementing custom entities

These are the steps I took to implement custom entities in ZfcBase + ZfcUser + ZfcUserDoctrineORM

  1. Comment ZfcUserDoctrineORM/config/module.config.php to remove default entities
  2. ZfcUser\src\ZfcUser\Model\Mapper\User.php
    • Change persist() to not require ZfcUser\Model\User
  3. ZfcUserDoctrineORM\src\ZfcUserDoctrineORM\Mapper\UserDoctrine.php
  • Change persist() to not require ZfcUser\Model\User

Installation fails: Argument 2 passed to TableGateway::__construct()

After following the installation instructions, I get an exception:

Catchable fatal error: Argument 2 passed to Zend\Db\TableGateway\TableGateway::__construct() must be an instance of Zend\Db\Adapter\Adapter, instance of PDO given in 
<my document root>/zfskeleton/vendor/ZendFramework/library/Zend/Db/TableGateway/TableGateway.php on line 100

I probably don't understand correctly how this is supposed to work, but I'm wondering why the 'dbmaster' alias should point to the PDO class. I've tried making it point to the Zend\Db\Adapter\Adapter class instead, but that results in a circular reference.

How to reproduce:

 git clone --recursive git://github.com/zendframework/ZendSkeletonApplication.git zfskeleton
cd zfskeleton/vendor
git clone https://github.com/ZF-Commons/ZfcBase.git
git clone https://github.com/ZF-Commons/ZfcUser.git
Add "ZfcBase" and "ZfcUser" to the modules array in configs/application.config.php
cd ..
cp ./vendor/ZfcUser/config/module.zfcuser.config.php.dist ./config/autoload/module.zfcuser.config.php
Copy the database config block to ./config/autoload/database.config.php , replace the CHANGEME blocks with real settings.
Remove comment in front of line 15 of module.zfcuser.config.php, change alias to 'dbmaster'.

Credential/Password StringLength filter : 6

Hi there,
I want to use ZfcUser for authentication but my user passwords may be less than 6 characters so $form->isValid() return false.
I would be great to have a MinPasswordStringLength to configure.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.