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

sam002/yii2-otp

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

  • Friday, January 19, 2018
  • by sam002
  • Repository
  • 1 Watchers
  • 10 Stars
  • 486 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 1 Open issues
  • 8 Versions
  • 2 % Grown

The README.md

yii2-otp

Code Climate SensioLabsInsight, (*1)

Latest Version Software License, (*2)

Build Status, (*3)

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

Installation

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

Either run, (*6)

composer require sam002/yii2-otp:~2.0.0

or add, (*7)

"sam002/yii2-otp" : "~2.0.0"

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

Usage

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

Configure, (*10)

 [
    'otp' => [
        'class' => Otp::className(),
        // 'totp' only now
        'algorithm' => sam002\otp\Otp::ALGORITHM_TOTP,
        
        // length of code
        'digits' => 6,
        
        //  Algorithm for hashing
        'digest' => 'sha1',
        
        // Label of application
        'label' => 'yii2-otp',
        
        // Uri to image (application icon)
        'imgLabelUrl' => Yii::to('/icon.png'),
        
        // Betwen 8 and 1024
        'secretLength' => 64,
        // Time interval in seconds, must be at least 1
        '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'
        // column|property name for get code and confirm secret
        //'codeAttribute' => 'secret'
        
        //Window in time for check authorithation (current +/- window*interval) 
        //'window' => 0
    ],
...
]
```

**Widget use**
Widget for generate init QR-code.
Read more about QrParams in the [qrcode-library](https://github.com/2amigos/qrcode-library).

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

field($model, 'secret')->widget(
                    OtpInit::className() ,[
                        'component'=>'otp',
                        
                        // link text
                        'link' => 'ADD OTP BY LINK',
                        
                        'QrParams' => [
                            // pixels width
                            'size' => 300,
                            
                            // margin around QR-code
                            'margin' => 10,
                            
                            // Path to logo on image
                            'logo' => '/icon.png',
                            
                            // Width logo on image
                            'logoWidth' => 50,
                            
                            // RGB color
                            'foregroundColor' => [0,0,0],
                            
                            // RGB color
                            'backgroundColor' => [255,255,255],
                            
                            // Qulity of QR: LOW, MEDIUM, HIGHT, QUARTILE
                            'level' => ErrorCorrectionLevelInterface::HIGH,
                            
                            // Image format: PNG, JPG, SVG, EPS
                            'type' => PngWriter::class,
                            
                            // Locale
                            'encoding' => 'UTF-8',
                            
                            // Text on image under QR code
                            'label' => 'QR code',
                            
                            // by default image create and save at Yii::$app->runtimePath . '/temporaryQR/'
                            'outfile' => '/tmp/'.uniqid(),
                            
                            // save or delete after generate
                            'save' => false,
                        ]
                ]); ?>

Further Information

Credits

License

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

The Versions

19/01 2018

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

 

The Development Requires

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

14/01 2018

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

 

The Development Requires

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

14/01 2018

2.0.0

2.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

 

The Development Requires

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

14/01 2018

dev-release/2.0.0

dev-release/2.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

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