2017 © Pedro Peláez
 

library two-factor

Two factor authentication.

image

kelunik/two-factor

Two factor authentication.

  • Saturday, July 14, 2018
  • by kelunik
  • Repository
  • 2 Watchers
  • 29 Stars
  • 197 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 4 Versions
  • 9 % Grown

The README.md

two-factor

Build Status CoverageStatus License, (*1)

kelunik/two-factor is a Google Authenticator compatible OATH implementation., (*2)

Requirements

  • PHP 5.5+

Installation

composer require kelunik/two-factor

Demo

There's a runnable demo contained in this repository., (*3)

Usage

Generate a secret per user

$oath = new Oath;

// this generates a key in binary format
$key = $oath->generateKey();

// store key for user

Let user setup two factor device

$oath = new Oath;
$key = "..."; // load user key from storage

// Use the URI to provide an easy to scan QR code
$uri = $oath->getUri($key);

// Alternatively display the key for manual input
$secret = $oath->encodeKey($key);

You can use your favourite JavaScript or PHP library to generate the QR code. For a working example, we're using qr.js., (*4)



Scan the following QR code and click continue once you're ready.

Validate TOTP value

$oath = new Oath;
$key = "..."; // load user key from storage
$isValid = $oath->verifyTotp($key, $totpValue);
// If the token is valid, ensure that it can't be used again.
// Because we use the default grace window size of two,
// we have to store the used TOTP value for at least 90 seconds,
// to prevent its usage explicitly.

The Versions

14/07 2018

dev-master

9999999-dev

Two factor authentication.

  Sources   Download

MIT

The Requires

 

The Development Requires

authentication 2fa oath two-factor totp hotp

14/07 2018

v1.1.1

1.1.1.0

Two factor authentication.

  Sources   Download

MIT

The Requires

 

The Development Requires

authentication 2fa oath two-factor totp hotp

13/06 2016

v1.1.0

1.1.0.0

Two factor authentication.

  Sources   Download

MIT

The Requires

 

The Development Requires

authentication 2fa oath two-factor totp hotp

18/04 2016

v1.0.0

1.0.0.0

Two factor authentication.

  Sources   Download

MIT

The Requires

 

The Development Requires

authentication 2fa oath two-factor totp hotp