1. Go to this page and download the library: Download lahthony/otp-auth-bundle library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
lahthony / otp-auth-bundle example snippets
// app/AppKernel.php
// ...
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
// ...
new LahthonyOTPAuthBundle\LahthonyOTPAuthBundle(),
);
// ...
}
// ...
}
//src/AppBundle/Entity/User
use LahthonyOTPAuthBundle\Model\OTPAuthInterface;
//...
class User implements OTPAuthInterface
{
/**
* This attribute needs to be stock in Database
* @var string
* @ORM\Column(name="secret_auth_key", type="string", length=255, nullable=true)
*/
private $secretAuthKey;
/**
* This attribute needs to be stocked in Database
* @var string
* @ORM\Column(name="recovery_key", type="string", length=255, nullable=true)
*/
private $recoveryKey;
/**
* This attribute will permit to do verification on user registration
* if he accepts 2Factor Authentication
* @var boolean
*/
private $OTP2Auth;
/**
* !!! DO NOT FORGET TO GENERATE GETTER AND SETTER FOR THESE THREE ATTRIBUTES !!!
*/
//We'll need email and password for the OTP Authentication reset
public function getEmail(){}
public function getPassword(){}
}
//src/AppBundle/Form/UserType
use LahthonyOTPAuthBundle\Form\EventSubscriber\Add2FactorAuthFieldSubscriber;
//...
class UserType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
//...
->addEventSubscriber(new Add2FactorAuthFieldSubscriber())
;
}
//...
}
//src/AppBundle/Form/UserEditType
use LahthonyOTPAuthBundle\Form\EventSubscriber\Add2FactorAuthFieldSubscriber;
//...
class UserType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
//...
->addEventSubscriber(new Add2FactorAuthFieldSubscriber())
;
}
//...
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.