Skip to content

Commit

Permalink
Merge pull request #5 from poetter-sebastian/develop
Browse files Browse the repository at this point in the history
# Updated readme and used unique name for composer repo name
  • Loading branch information
poetter-sebastian authored Dec 9, 2023
2 parents 3bf1ce8 + 3ff9198 commit 2a1d7b1
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 3 deletions.
81 changes: 80 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,80 @@
# SimpleThenticator
# SimpleThenticator

* Copyright (c) 2023, [https://poetter-sebastian.github.io](https://poetter-sebastian.github.io/)
* Author: Sebastian Pötter, ([@PHPGangsta](https://github.com/PHPGangsta/GoogleAuthenticator), [contributors](https://github.com/PHPGangsta/GoogleAuthenticator/graphs/contributors)) and [contributors](https://github.com/poetter-sebastian/SimpleThenticator/graphs/contributors)
* Licensed under the [BSD 2-Clause "Simplified" License](https://github.com/poetter-sebastian/SimpleThenticator/blob/main/LICENSE).

<p align="center">
<a href="LICENSE" target="_blank">
<img alt="Software License" src="https://img.shields.io/badge/lisence-BSD_2_Clause-green?style=flat-square">
</a>
<!--
<a href="https://codecov.io/gh/cakephp/poetter-sebastian/SimpleThenticator/4.x" target="_blank">
<img alt="Coverage Status" src="https://img.shields.io/codecov/c/github/cakephp/cakephp?style=flat-square">
</a>
<a href="https://packagist.org/packages/poetter-sebastian/SimpleThenticator" target="_blank">
<img alt="Total Downloads" src="https://img.shields.io/packagist/dt/poetter-sebastian/SimpleThenticator.svg?style=flat-square">
</a>
<a href="https://packagist.org/packages/poetter-sebastian/SimpleThenticator" target="_blank">
<img alt="Latest Stable Version" src="https://img.shields.io/packagist/v/poetter-sebastian/SimpleThenticator.svg?style=flat-square&label=stable">
</a>-->
</p>

This class can generate secrets, generate codes, validate codes and present a QR-Code for scanning the secret. It implements TOTP
according to [RFC6238](https://tools.ietf.org/html/rfc6238)

Example:
------

Look at the function [TestGenerator()](https://github.com/poetter-sebastian/SimpleThenticator/blob/main/tests/SimpleAuthenticatorTest.php) in [tests](https://github.com/poetter-sebastian/SimpleThenticator/tree/main/tests)

```php
$auth = new SimpleAuthenticator();
try
{
$secret = $auth->createSecret();
}
catch (Exception $e)
{
echo $e->getMessage();
exit();
}
echo "Secret is: ".$secret."\n";

$qrCodeUrl = $auth->getQRCodeGoogleUrl($secret, 'Testo@test.test', 'Business');
echo "QR-Code: ".$qrCodeUrl."\n";

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

echo $auth->verifyCode($secret, $oneCode, 2)? 'OK': 'NOT OK';

```
output:
```
Secret is: S4VWK6CWPA3PMU2HZM2YEDZGSF2DQL3V
Google Charts URL for the QR-Code: https://api.qrserver.com/v1/create-qr-code/?data=otpauth%3A%2F%2Ftotp%2FVintage+Story%3ATesto%40test.test%3Fsecret%3DS4VWK6CWPA3PMU2HZM2YEDZGSF2DQL3V%26algorithm%3DSHA256%26issuer%3DVintage+Story&size=200x200&ecc=M
Checking Code '439195' and Secret 'S4VWK6CWPA3PMU2HZM2YEDZGSF2DQL3V':
OK
```

Installation:
-------------
### [Composer](https://getcomposer.org/doc/01-basic-usage.md)

- To use this package perform the following command:

```composer require sebastiandevs/simplethenticator```

### Simple usage

- To use the class just import the [SimpleAuthenticator.php](https://github.com/poetter-sebastian/SimpleThenticator/blob/main/src/SimpleAuthenticator.php) as ```require_once()``` in your PHP code

Run Tests:
----------

- All tests are inside [tests](https://github.com/poetter-sebastian/SimpleThenticator/tree/main/tests) folder.
- Execute `composer run-script build-dev` to install all dependencies
- Execute `composer run-script test` to run all tests in the test folder
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"name": "sebastian/simplethenticator",
"name": "sebastiandevs/simplethenticator",
"description": "TOTP based on https://github.com/PHPGangsta/GoogleAuthenticator updated and reworked to php8.2 because of inactivity of the original creator.",
"keywords": ["TOTP","2FA", "2 factor authenticator library"],
"homepage": "https://poetter-sebastian.github.io/",
"minimum-stability": "stable",
"license": "BSD-2-Clause",
"authors": [
Expand Down
2 changes: 1 addition & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2a1d7b1

Please sign in to comment.