2017 © Pedro Peláez
 

library rad-user

Simply handle password encryption and salt generation

image

knplabs/rad-user

Simply handle password encryption and salt generation

  • Thursday, September 21, 2017
  • by Knplabs
  • Repository
  • 21 Watchers
  • 6 Stars
  • 50,461 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 7 Open issues
  • 9 Versions
  • 2 % Grown

The README.md

DEPRECATED

Unfortunately we decided to not maintain this project anymore (see why). If you want to mark another package as a replacement for this one please send an email to hello@knplabs.com., (*1)

Rapid Application Development : User

A Symfony bundle to simply handle password encryption and salt generation, (*2)

Build Status Scrutinizer Code Quality Latest Stable Version Total Downloads Latest Unstable Version License, (*3)

Official maintainers:

Installation

composer require knplabs/rad-user:~2.0
class AppKernel
{
    function registerBundles()
    {
        $bundles = array(
            //...
            new Knp\Rad\User\Bundle\UserBundle(),
            //...
        );

        //...

        return $bundles;
    }
}

Usages

I want to auto-generate my user salt

The salt feature is deprecated since PHP 5.5 and BCrypt usage. Please upgrade your version of PHP and use BCrypt., (*4)

Your User model should implement the Knp\Rad\User\HasSalt interface., (*5)


namespace App\Entity; use Doctrine\ORM\Mapping as ORM; use Knp\Rad\User\HasSalt; /** * @ORM\Entity */ class User implements HasSalt { use HasSalt\HasSalt; //You can also use this trait /** * @ORM\Id * @ORM\GeneratedValue * @ORM\Column(type="integer") */ private $id; /** * @ORM\Column */ private $salt; }

Now, before your user is inserted into your database, the salt will be auto-generated., (*6)

I want to auto-generate my user password

Your User model should implement the Knp\Rad\User\HasInitialPassword interface., (*7)


namespace App\Entity; use Doctrine\ORM\Mapping as ORM; use Knp\Rad\User\HasInitialPassword; /** * @ORM\Entity */ class User implements HasInitialPassword { use HasInitialPassword\HasInitialPassword; // You can also use this trait /** * @ORM\Id * @ORM\GeneratedValue * @ORM\Column(type="integer") */ private $id; /** * @ORM\Column */ private $password; }

Now, before your user is inserted or updated into your database, then the plain password will be automaticly generated., (*8)

I want to auto-encode my user password

Your User model should implement the Knp\Rad\User\HasPassword interface., (*9)


namespace App\Entity; use Doctrine\ORM\Mapping as ORM; use Knp\Rad\User\HasPassword; /** * @ORM\Entity */ class User implements HasPassword { use HasPassword\HasPassword; // You can also use this trait /** * @ORM\Id * @ORM\GeneratedValue * @ORM\Column(type="integer") */ private $id; /** * @ORM\Column */ private $password; }

Now, before your user is inserted or updated into your database, if you have set the attribute 'plainPassword', then the password will be automaticly generated., (*10)

WARNING

The Knp\Rad\User\HasPassword\HasPassword trait use the Knp\Rad\User\HasInitialPassword\HasInitialPassword trait. So don't use both into the same class or you will have a method conflict., (*11)

Some tips

Using with MongoDB or CouchDB Object Document Mapper

The knp/rad-user library is also compatible with MongoDB and CouchDB, (*12)

The Versions

16/12 2016

dev-feature/add-random-bytes-implementation

dev-feature/add-random-bytes-implementation

Simply handle password encryption and salt generation

  Sources   Download

MIT

The Requires

 

The Development Requires