An open API service indexing awesome lists of open source software.

https://github.com/atomjoy/google-authenticator

2FA two-step verification with php and Google Authenticator in Laravel.
https://github.com/atomjoy/google-authenticator

google-authenticator google-authenticator-php

Last synced: 2 months ago
JSON representation

2FA two-step verification with php and Google Authenticator in Laravel.

Awesome Lists containing this project

README

          

# PHP Google Authenticator

2FA two-step verification with php and Google Authenticator in Laravel.

## Install

```sh
composer require atomjoy/google-authenticator
```

## GoogleAuthenticator in Laravel

How to generate code from user secret like in GoogleAuthenticator on Android but from php script.

```php
createSecret();

// QR-Code image
$url = $ga->getQRCodeUrl('Appname:user@example.com', $secret);

// Show user qr-code
echo "

New secret is: " . $secret . "

";
echo '

Google Charts URL for the QR-Code:

';
echo '

';
} else {
// Generate code from user secret like in GoogleAuthenticator on Android but from php script
// Past this code in github 2fa confirm code form
$code = $ga->getCode($secret);
echo "

Checking code " . $code . " and Secret " . $secret . " use this code in 2fa on github, facebook, ...

";

// Confirm code (allow 2*30sec clock tolerance)
if ($ga->verifyCode($secret, $code, 2)) {
echo '

OK

';
} else {
echo '

FAILED

';
}
}
});
```

## Enable github two factor with php script

```sh
php artisan serve

# 1. Get and save generated secret when enabling two-factor authentication in panel settings
# QR-code example github_2fa_secret: FA7DKAS2MK6SH3BN

# 2. Enable or Login with 2fa secret
# Get 6-digit code and past in github 2fa form 😄 (refresh every 30 seconds)
http://127.0.0.1:8000/test/2fa/google/{github_2fa_secret}
```