jocic/google-authenticator

Complete & easy-to-implement MFA solution for use with Google Authenticator App.

1.0.0 2019-01-07 02:57 UTC

This package is auto-updated.

Last update: 2024-03-19 20:53:44 UTC


README

Build Status Coverage Status Codacy Badge Latest Stable Version License

Google Authenticator is a mini PHP library for implementing Multi-Factor Authentication by utilizing Google's Authenticator App. It was written to simplify the usually complicated implementation process.

Project Image

Following specifications were referenced:

  • RFC 4226 - HMAC-Based One-Time Password Algorithm
  • RFC 6238 - TOTP: Time-Based One-Time Password Algorithm
  • RFC 6287 - OCRA: OATH Challenge-Response Algorithm

Buy Me Coffee

Song of the project: Iron Maiden - The Trooper

Versioning Scheme

I use a 3-digit Semantic Versioning identifier, for example 1.0.2. These digits have the following meaning:

  • The first digit (1) specifies the MAJOR version number.
  • The second digit (0) specifies the MINOR version number.
  • The third digit (2) specifies the PATCH version number.

Complete documentation can be found by following the link above.

Examples

Following examples should be more then enough to get you started. I tried my best to make them as simple as possible so that everyone, even junior developers, can successfully use them for implementing two-factor authentication.

  1. Creating a Secret
  2. Secret Creation Methods
  3. Setting Existing Secrets
  4. Creating an Account
  5. Account Management
  6. QR Codes
  7. Code Validation

For additional examples please review the official project's wiki.

Requirements

You only need to have PHP >=7.0 available on your system to use Google Authenticator in your application. However, for running unit tests, you need to have the following extensions installed:

Installation

There's two ways you can add Google Authenticator library to your project:

  • Copying files from the "source" directory to your project and requiring the "Autoload.php" script (this includes doing the same for project's dependencies ex. Encoders)
  • Via Composer, by executing the command below
composer require jocic/google-authenticator 1.0.0

Tests

Following unit tests are available:

  • Essentials - Tests for library's essentials ex. Autoloader, Base 32 encoder, etc.
  • QR Generators - Tests for available QR code generators in the library.
  • Elements - Tests for library's core elements ex. Secret, Account, etc.

You can execute them easily from the terminal like in the example below.

bash ./scripts/phpunit.sh --testsuite essentials
bash ./scripts/phpunit.sh --testsuite qr-generators
bash ./scripts/phpunit.sh --testsuite elements

Please don’t forget to install necessary dependencies before attempting to do the God's work above. They may be important.

bash ./scripts/composer.sh install

Contribution

Please review the following documents if you are planning to contribute to the project:

Integration

My hourly rate is fairly reasonable so, if you need help with integrating Google Authenticator to your existing project, feel free to contact me via the email below.

Integration inquiries: office@djordjejocic.com

Support

Please don't hesitate to contact me if you have any questions, ideas, or concerns.

My Twitter account is: @jocic_91

My support E-Mail address is: support@djordjejocic.com

Copyright & License

Copyright (C) 2018 Đorđe Jocić

Licensed under the MIT license.