2017 © Pedro Peláez
 

library doorman

RFC compliant Two Factor Authentication for Time-Based One-Time Password and HMAC-Based One-Time Password algorithm with support for Google Authenticator

image

battlerattle/doorman

RFC compliant Two Factor Authentication for Time-Based One-Time Password and HMAC-Based One-Time Password algorithm with support for Google Authenticator

  • Saturday, August 19, 2017
  • by BattleRattle
  • Repository
  • 1 Watchers
  • 6 Stars
  • 38 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Doorman

Build status: Build Status, (*1)

Doorman is an RFC-compliant implementation of the TOTP (Time-Based One-Time Passsword, RFC 6238) algorithm, which is commonly used for Two Factor Authentication., (*2)

A wrapper for the Google Authenticator - a key manager and code generator, which can be downloaded for free, is also available. It also works for other 3rd party code generators, that use the TOTP algorithm., (*3)

Requirements

You need at least a 64-bit version of PHP 5.4 or HHVM., (*4)

Installation via Composer

Use Composer CLI:, (*5)

php composer.phar require battlerattle/doorman:1.0.*@dev

Or add battlerattle/doorman to your composer.json:, (*6)

"require": {
    "battlerattle/doorman": "1.0.*@dev"
},

Usage

This is a pretty basic example, (*7)

use BattleRattle\Doorman\Authentication\TimeBasedAuthenticator;

// get the code from user input
$code = '...';

// the user's secret key
$key = '...';

$authenticator = new TimeBasedAuthenticator();
$result = $authenticator->authenticate($key, $code);

if ($result) {
    echo 'Welcome, you successfully logged in';
} else {
    echo 'Nope, please try again';
}

Google Authenticator

In this example we use the Google Authenticator, which uses base32-encoded keys, that will be decoded internally., (*8)

use BattleRattle\Doorman\Authentication\GoogleAuthenticator;

$code = '...';
$key = '...';

$authenticator = new GoogleAuthenticator();
$result = $authenticator->authenticate($key, $code);

if ($result) {
    echo 'Welcome, you successfully logged in';
} else {
    echo 'Nope, please try again';
}

Key Generator

This generator creates "Google Authenticator"-compliant keys:, (*9)

use BattleRattle\Doorman\KeyGeneration\GoogleAuthKeyGenerator;

$keyGenerator = new GoogleAuthKeyGenerator;
$key = $keyGenerator->generateKey();

// it's good practice to split the key into chunks of 4 characters for better readability
$formattedKey = implode(' ', str_split($key, 4));

echo 'Add this key to your authenticator: ' . $formattedKey;

References

The Versions

19/08 2017

dev-master

9999999-dev

RFC compliant Two Factor Authentication for Time-Based One-Time Password and HMAC-Based One-Time Password algorithm with support for Google Authenticator

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

by Norman Soetbeer

google authenticator oath totp one-time password rfc 6238 two factor authentication

19/08 2017

v1.1.0

1.1.0.0

RFC compliant Two Factor Authentication for Time-Based One-Time Password and HMAC-Based One-Time Password algorithm with support for Google Authenticator

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

by Norman Soetbeer

google authenticator oath totp one-time password rfc 6238 two factor authentication

19/08 2017

dev-task/update-travis-ci

dev-task/update-travis-ci

RFC compliant Two Factor Authentication for Time-Based One-Time Password and HMAC-Based One-Time Password algorithm with support for Google Authenticator

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

by Norman Soetbeer

google authenticator oath totp one-time password rfc 6238 two factor authentication