2017 © Pedro Peláez
 

yii2-extension yii2-otp

YII2 extension for generating one time passwords according to RFC 4226/6238 (HOTP/TOTP Algorithm) and authentication widget

image

infoburp/yii2-otp

YII2 extension for generating one time passwords according to RFC 4226/6238 (HOTP/TOTP Algorithm) and authentication widget

  • Tuesday, October 10, 2017
  • by infoburp
  • Repository
  • 1 Watchers
  • 0 Stars
  • 28 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 8 Versions
  • 8 % Grown

The README.md

yii2-otp

Code Climate SensioLabsInsight, (*1)

Latest Version Software License, (*2)

YII2 extension for generating one time passwords according to RFC 4226 (HOTP Algorithm) and the RFC 6238 (TOTP Algorithm), (*3)

Installation

The preferred way to install this extension is through composer., (*4)

Either run, (*5)

composer require infoburp/yii2-otp:~0.1.1

or add, (*6)

"infoburp/yii2-otp" : "~0.1.1"

to the require section of your application's composer.json file., (*7)

Usage

After extension is installed you need to setup auth client collection application component:, (*8)

Configure, (*9)

 [
    'otp' => [
        'class' => 'Otp',
        // 'totp' only now
        'algorithm' => infoburp\otp\Collection::ALGORITHM_TOTP
        
        // length of code
        'digits' => 6,
        
        //  Algorithm for hashing
        'digets' => 'sha1',
        
        // Lable of application
        'lable' => 'yii2-otp',
        
        // Uri to image (application icon)
        'imgLabelUrl' => Yii::to('/icon.png'),
        
        // Betwen 8 and 1024
        'secretLength' => 64
        'interval'
    ],
...
]
```

**Add behavior**
Add any model column for storing secure code. //My case: the use of two-factor authentication 

```php
 [
    'otp' => [
        'class' => OtpBehavior::className(),
        // Component name
        'component' => 'otp',
        
        // column|property name for get and set secure phrase
        //'secretAttribute' => 'secret'
        
        //Window in time for check authorithation (current +/- window*interval) 
        //'window' => 0
    ],
...
]
```

**Widget use**
Widget for generate init QR-code

```php
use infoburp\otp\widgets\OtpInit;

field($model, 'otpSecret')->widget(
                    OtpInit::className() ,[
                        'component'=>'otp',
                        
                        // link text
                        'link' => 'ADD OTP BY LINK',
                        
                        'QrParams' => [
                            // pixels per cell
                            'size' => 3,
                            
                            // margin around QR-code
                            'margin' => 5,
                            
                            // by default image create and save at Yii::$app->runtimePath . '/temporaryQR/'
                            'outfile' => '/tmp/'.uniqid(),
                            
                            // save or delete after generate
                            'save' => false,
                        ]
                ]); ?>

Validation. Additional examples, (*10)

// login view
field($model, 'username') ?>
            <?php echo $form->field($model, 'otp')->passwordInput() ?>
            ...

// login form model
<?php
     /**
     * Validates the OTP.
     */
    public function validateOtp()
    {
        if (!$this->hasErrors()) {
            $user = $this->getUser();
            if (!$user || !$user->validateOtpSecret($this->otp)) {
                $this->addError('otp', Yii::t('common', 'Incorrect code.'));
            }
        }
    }

Further Information

Credits

License

The LGPLv3 License. Please see License File for more information., (*11)

The Versions

10/10 2017

dev-master

9999999-dev

YII2 extension for generating one time passwords according to RFC 4226/6238 (HOTP/TOTP Algorithm) and authentication widget

  Sources   Download

LGPL-3.0

The Requires

 

by Graeme Wolfendale

authentication yii2 otp 2fa two-factor totp hotp two-factor authentication

10/10 2017

1.0.3

1.0.3.0

YII2 extension for generating one time passwords according to RFC 4226/6238 (HOTP/TOTP Algorithm) and authentication widget

  Sources   Download

LGPL-3.0

The Requires

 

by Graeme Wolfendale

authentication yii2 otp 2fa two-factor totp hotp two-factor authentication

09/10 2017

1.0.2

1.0.2.0

YII2 extension for generating one time passwords according to RFC 4226/6238 (HOTP/TOTP Algorithm) and authentication widget

  Sources   Download

LGPL-3.0

The Requires

 

by Graeme Wolfendale

authentication yii2 otp 2fa two-factor totp hotp two-factor authentication

08/05 2017

dev-develop

dev-develop

YII2 extension for generating one time passwords according to RFC 4226/6238 (HOTP/TOTP Algorithm) and authentication widget

  Sources   Download

LGPL-3.0

The Requires

 

authentication yii2 otp 2fa two-factor totp hotp two-factor authentication

20/12 2016

1.0.1

1.0.1.0

YII2 extension for generating one time passwords according to RFC 4226/6238 (HOTP/TOTP Algorithm) and authentication widget

  Sources   Download

LGPL-3.0

The Requires

 

authentication yii2 otp 2fa two-factor totp hotp two-factor authentication

19/12 2016

1.0.0

1.0.0.0

YII2 extension for generating one time passwords according to RFC 4226/6238 (HOTP/TOTP Algorithm) and authentication widget

  Sources   Download

LGPL-3.0

The Requires

 

authentication yii2 otp 2fa two-factor totp hotp two-factor authentication

22/10 2016

0.1.1

0.1.1.0

YII2 extension for generating one time passwords according to RFC 4226/6238 (HOTP/TOTP Algorithm) and authentication widget

  Sources   Download

LGPL-3.0

The Requires

 

authentication yii2 otp 2fa two-factor totp hotp two-factor authentication

06/02 2016

0.1

0.1.0.0

YII2 extension for generating one time passwords according to RFC 4226/6238 (HOTP/TOTP Algorithm) and authentication widget

  Sources   Download

LGPL-3.0

The Requires

 

The Development Requires

authentication yii2 otp 2fa two-factor totp hotp two-factor authentication