2017 © Pedro Peláez
 

library google-auth

Google Authenticator 2-factor authentication

image

delboy1978uk/google-auth

Google Authenticator 2-factor authentication

  • Thursday, November 23, 2017
  • by delboy1978uk
  • Repository
  • 1 Watchers
  • 0 Stars
  • 6 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

google-auth

Latest Stable Version Total Downloads Latest Unstable Version License
Build Status Code Coverage Scrutinizer Code Quality
, (*1)

This PHP class can be used to interact with the Google Authenticator mobile app for 2-factor-authentication. This class can generate secrets, generate codes, validate codes and present a QR-Code for scanning the secret. It implements TOTP according to RFC6238, (*2)

For a secure installation you have to make sure that used codes cannot be reused (replay-attack). You also need to limit the number of verifications, to fight against brute-force attacks. For example you could limit the amount of verifications to 10 tries within 10 minutes for one IP address (or IPv6 block). It depends on your environment., (*3)

Forked from PHPGangsta's lib - see copyright notice., (*4)

installation

Installation is via composer, (*5)

composer require delboy1978uk/google-auth

usage

See following example:, (*6)

<?php

use Del\Auth\GoogleAuthenticator;

$ga = new GoogleAuthenticator();
$secret = $ga->createSecret();
echo "Secret is: ".$secret."\n\n";

$qrCodeUrl = $ga->getQRCodeGoogleUrl('Blog', $secret);
echo "Google Charts URL for the QR-Code: ".$qrCodeUrl."\n\n";

$oneCode = $ga->getCode($secret);
echo "Checking Code '$oneCode' and Secret '$secret':\n";

$checkResult = $ga->verifyCode($secret, $oneCode, 2);    // 2 = 2*30sec clock tolerance

$checkResult is a boolean true/false Running the script provides the following output:, (*7)

Secret is: OQB6ZZGYHCPSX4AK

Google Charts URL for the QR-Code: https://www.google.com/chart?chs=200x200&chld=M|0&cht=qr&chl=otpauth://totp/infoATphpgangsta.de%3Fsecret%3DOQB6ZZGYHCPSX4AK

Checking Code '848634' and Secret 'OQB6ZZGYHCPSX4AK':
OK

The Versions

23/11 2017

dev-master

9999999-dev

Google Authenticator 2-factor authentication

  Sources   Download

BSD-4-Clause

The Requires

  • php >=5.3

 

The Development Requires

totp googleauthenticator rfc6238

23/11 2017

v1.0.4

1.0.4.0

Google Authenticator 2-factor authentication

  Sources   Download

BSD-4-Clause

The Requires

  • php >=5.3

 

The Development Requires

totp googleauthenticator rfc6238