├── phpstan.neon.dist ├── src ├── Facades │ ├── AuthyApp.php │ ├── AuthyToken.php │ └── AuthyUser.php └── Providers │ └── AuthyServiceProvider.php ├── LICENSE ├── CONTRIBUTING.md ├── composer.json ├── CODE_OF_CONDUCT.md ├── CHANGELOG.md └── README.md /phpstan.neon.dist: -------------------------------------------------------------------------------- 1 | includes: 2 | - ./vendor/nunomaduro/larastan/extension.neon 3 | parameters: 4 | level: 5 5 | paths: 6 | - src 7 | -------------------------------------------------------------------------------- /src/Facades/AuthyApp.php: -------------------------------------------------------------------------------- 1 | app->singleton('rinvex.authy.app', function ($app) use ($httpClient, $key) { 24 | return new AuthyApp($httpClient, $key); 25 | }); 26 | $this->app->alias('rinvex.authy.app', AuthyApp::class); 27 | 28 | $this->app->singleton('rinvex.authy.user', function ($app) use ($httpClient, $key) { 29 | return new AuthyUser($httpClient, $key); 30 | }); 31 | $this->app->alias('rinvex.authy.user', AuthyUser::class); 32 | 33 | $this->app->singleton('rinvex.authy.token', function ($app) use ($httpClient, $key) { 34 | return new AuthyToken($httpClient, $key); 35 | }); 36 | $this->app->alias('rinvex.authy.token', AuthyToken::class); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contribution Guide 2 | 3 | This project adheres to the following standards and practices. 4 | 5 | 6 | ## Versioning 7 | 8 | This project is versioned under the [Semantic Versioning](http://semver.org/) guidelines as much as possible. 9 | 10 | Releases will be numbered with the following format: 11 | 12 | - `..` 13 | - `..` 14 | 15 | And constructed with the following guidelines: 16 | 17 | - Breaking backward compatibility bumps the major and resets the minor and patch. 18 | - New additions without breaking backward compatibility bump the minor and reset the patch. 19 | - Bug fixes and misc changes bump the patch. 20 | 21 | 22 | ## Pull Requests 23 | 24 | The pull request process differs for new features and bugs. 25 | 26 | Pull requests for bugs may be sent without creating any proposal issue. If you believe that you know of a solution for a bug that has been filed, please leave a comment detailing your proposed fix or create a pull request with the fix mentioning that issue id. 27 | 28 | 29 | ## Coding Standards 30 | 31 | This project follows the FIG PHP Standards Recommendations compliant with the [PSR-1: Basic Coding Standard](http://www.php-fig.org/psr/psr-1/), [PSR-2: Coding Style Guide](http://www.php-fig.org/psr/psr-2/) and [PSR-4: Autoloader](http://www.php-fig.org/psr/psr-4/) to ensure a high level of interoperability between shared PHP code. If you notice any compliance oversights, please send a patch via pull request. 32 | 33 | 34 | ## Feature Requests 35 | 36 | If you have a proposal or a feature request, you may create an issue with `[Proposal]` in the title. 37 | 38 | The proposal should also describe the new feature, as well as implementation ideas. The proposal will then be reviewed and either approved or denied. Once a proposal is approved, a pull request may be created implementing the new feature. 39 | 40 | 41 | ## Git Flow 42 | 43 | This project follows [Git-Flow](http://nvie.com/posts/a-successful-git-branching-model/), and as such has `master` (latest stable releases), `develop` (latest WIP development) and X.Y support branches (when there's multiple major versions). 44 | 45 | Accordingly all pull requests MUST be sent to the `develop` branch. 46 | 47 | > **Note:** Pull requests which do not follow these guidelines will be closed without any further notice. 48 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "rinvex/laravel-authy", 3 | "description": "Rinvex Authy is a simple wrapper for Authy TOTP, the best rated Two-Factor Authentication service for consumers, simplest 2fa Rest API for developers and a strong authentication platform for the enterprise.", 4 | "type": "library", 5 | "keywords": [ 6 | "sms", 7 | "call", 8 | "authy", 9 | "message", 10 | "security", 11 | "twofactor", 12 | "verification", 13 | "authentication", 14 | "automated", 15 | "register", 16 | "laravel", 17 | "rinvex", 18 | "phone", 19 | "token" 20 | ], 21 | "license": "MIT", 22 | "homepage": "https://rinvex.com", 23 | "support": { 24 | "email": "help@rinvex.com", 25 | "issues": "https://github.com/rinvex/laravel-authy/issues", 26 | "source": "https://github.com/rinvex/laravel-authy", 27 | "docs": "https://github.com/rinvex/laravel-authy/README.md" 28 | }, 29 | "authors": [ 30 | { 31 | "name": "Rinvex LLC", 32 | "homepage": "https://rinvex.com", 33 | "email": "help@rinvex.com" 34 | }, 35 | { 36 | "name": "Abdelrahman Omran", 37 | "homepage": "https://omranic.com", 38 | "email": "me@omranic.com", 39 | "role": "Project Lead" 40 | }, 41 | { 42 | "name": "The Generous Laravel Community", 43 | "homepage": "https://github.com/rinvex/laravel-authy/contributors" 44 | } 45 | ], 46 | "require": { 47 | "php": "^8.1.0", 48 | "guzzlehttp/guzzle": "^7.4.0", 49 | "illuminate/support": "^10.0.0 || ^11.0.0", 50 | "rinvex/authy": "^7.0.0" 51 | }, 52 | "require-dev": { 53 | "codedungeon/phpunit-result-printer": "^0.32.0", 54 | "illuminate/container": "^10.0.0 || ^11.0.0", 55 | "phpunit/phpunit": "^10.1.0" 56 | }, 57 | "autoload": { 58 | "psr-4": { 59 | "Rinvex\\Authy\\": "src" 60 | } 61 | }, 62 | "autoload-dev": { 63 | "psr-4": { 64 | "Rinvex\\Authy\\Tests\\": "tests" 65 | } 66 | }, 67 | "scripts": { 68 | "test": "vendor/bin/phpunit" 69 | }, 70 | "config": { 71 | "sort-packages": true, 72 | "preferred-install": "dist", 73 | "optimize-autoloader": true 74 | }, 75 | "extra": { 76 | "laravel": { 77 | "providers": [ 78 | "Rinvex\\Authy\\Providers\\AuthyServiceProvider" 79 | ], 80 | "aliases": { 81 | "AuthyApp": "Rinvex\\Authy\\Facades\\AuthyApp", 82 | "AuthyUser": "Rinvex\\Authy\\Facades\\AuthyUser", 83 | "AuthyToken": "Rinvex\\Authy\\Facades\\AuthyToken" 84 | } 85 | } 86 | }, 87 | "minimum-stability": "dev", 88 | "prefer-stable": true 89 | } 90 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and maintainers pledge to making participation in our project and 7 | our community a harassment-free experience for everyone, regardless of age, body 8 | size, disability, ethnicity, gender identity and expression, level of experience, 9 | nationality, personal appearance, race, religion, or sexual identity and 10 | orientation. 11 | 12 | ## Our Standards 13 | 14 | Examples of behavior that contributes to creating a positive environment 15 | include: 16 | 17 | * Using welcoming and inclusive language 18 | * Being respectful of differing viewpoints and experiences 19 | * Gracefully accepting constructive criticism 20 | * Focusing on what is best for the community 21 | * Showing empathy towards other community members 22 | 23 | Examples of unacceptable behavior by participants include: 24 | 25 | * The use of sexualized language or imagery and unwelcome sexual attention or 26 | advances 27 | * Trolling, insulting/derogatory comments, and personal or political attacks 28 | * Public or private harassment 29 | * Publishing others' private information, such as a physical or electronic 30 | address, without explicit permission 31 | * Other conduct which could reasonably be considered inappropriate in a 32 | professional setting 33 | 34 | ## Our Responsibilities 35 | 36 | Project maintainers are responsible for clarifying the standards of acceptable 37 | behavior and are expected to take appropriate and fair corrective action in 38 | response to any instances of unacceptable behavior. 39 | 40 | Project maintainers have the right and responsibility to remove, edit, or 41 | reject comments, commits, code, wiki edits, issues, and other contributions 42 | that are not aligned to this Code of Conduct, or to ban temporarily or 43 | permanently any contributor for other behaviors that they deem inappropriate, 44 | threatening, offensive, or harmful. 45 | 46 | ## Scope 47 | 48 | This Code of Conduct applies both within project spaces and in public spaces 49 | when an individual is representing the project or its community. Examples of 50 | representing a project or community include using an official project e-mail 51 | address, posting via an official social media account, or acting as an appointed 52 | representative at an online or offline event. Representation of a project may be 53 | further defined and clarified by project maintainers. 54 | 55 | ## Enforcement 56 | 57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 58 | reported by contacting the project team at [help@rinvex.com](mailto:help@rinvex.com). All 59 | complaints will be reviewed and investigated and will result in a response that 60 | is deemed necessary and appropriate to the circumstances. The project team is 61 | obligated to maintain confidentiality with regard to the reporter of an incident. 62 | Further details of specific enforcement policies may be posted separately. 63 | 64 | Project maintainers who do not follow or enforce the Code of Conduct in good 65 | faith may face temporary or permanent repercussions as determined by other 66 | members of the project's leadership. 67 | 68 | ## Attribution 69 | 70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 71 | available at [http://contributor-covenant.org/version/1/4][version] 72 | 73 | [homepage]: http://contributor-covenant.org 74 | [version]: http://contributor-covenant.org/version/1/4/ 75 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Rinvex Authy Changelog 2 | 3 | All notable changes to this project will be documented in this file. 4 | 5 | This project adheres to [Semantic Versioning](CONTRIBUTING.md). 6 | 7 | 8 | ## [v10.1.0] - 2023-05-02 9 | - 422ace4: Add support for Laravel v11, and drop support for Laravel v9 10 | - 59d0321: Update phpunit to v10.1 from v9.5 11 | - 61632d8: Merge tag 'v10.0.0' into develop 12 | 13 | ## [v10.0.0] - 2023-01-09 14 | - Drop PHP v8.0 support and update composer dependencies 15 | 16 | ## [v9.1.0] - 2022-02-14 17 | - Update composer dependencies to Laravel v9 18 | 19 | ## [v9.0.0] - 2021-08-22 20 | - Drop PHP v7 support, and upgrade rinvex package dependencies to next major version 21 | - Update composer dependencies 22 | - Upgrade to GitHub-native Dependabot (#18) 23 | - Enable StyleCI risky mode 24 | 25 | ## [v8.0.1] - 2020-12-25 26 | - Add support for PHP v8 27 | 28 | ## [v8.0.0] - 2020-12-22 29 | - Upgrade to Laravel v8 30 | 31 | ## [v7.1.0] - 2020-06-15 32 | - Drop PHP 7.2 & 7.3 support from travis 33 | 34 | ## [v7.0.0] - 2020-03-15 35 | - Upgrade to Laravel v7.1.x & PHP v7.4.x 36 | 37 | ## [v6.0.1] - 2020-03-13 38 | - Tweak TravisCI config 39 | - Update StyleCI config 40 | 41 | ## [v6.0.0] - 2019-09-23 42 | - Upgrade to Laravel v6 and update dependencies 43 | 44 | ## [v5.1.0] - 2019-06-02 45 | - Update composer deps 46 | - Drop PHP 7.1 travis test 47 | 48 | ## [v5.0.0] - 2019-03-03 49 | - Rename environment variable QUEUE_DRIVER to QUEUE_CONNECTION 50 | - Require PHP 7.2 & Laravel 5.8 51 | - Apply PHPUnit 8 updates 52 | 53 | ## [v4.0.1] - 2018-12-22 54 | - Update composer dependencies 55 | - Add PHP 7.3 support to travis 56 | 57 | ## [v4.0.0] - 2018-10-01 58 | - Enforce Consistency 59 | - Support Laravel 5.7+ 60 | 61 | ## [v3.0.1] - 2018-09-22 62 | - Update travis php versions 63 | - Drop StyleCI multi-language support (paid feature now!) 64 | - Update composer dependencies 65 | - Prepare and tweak testing configuration 66 | - Highlight variables in strings explicitly 67 | - Update StyleCI options 68 | - Update PHPUnit options 69 | 70 | ## [v3.0.0] - 2018-02-18 71 | - Update supplementary files 72 | - Update composer dependencies 73 | - Support Auto-Discovery 74 | - Fix deprecated PHPUnit TestCase namespace 75 | - Simplify installation steps after utilizing L5.5 auto discovery 76 | - Add PHPUnitPrettyResultPrinter 77 | - Drop Laravel v5.5 support 78 | - Add Laravel v5.6 support 79 | - Require PHP v7.1.3 80 | 81 | ## [v2.0.1] - 2017-03-06 82 | - Update readme and composer dependencies 83 | - Fix \GuzzleHttp\ClientInterface initialization issues 84 | 85 | ## [v2.0.0] - 2016-12-20 86 | - Simplify code 87 | - Add test suites 88 | - Drop LTS support 89 | - Update Code Style 90 | - Defer service provider 91 | - Drop Authy deprecated sandbox api support 92 | - Push dependencies forward and require php7 93 | 94 | ## [v1.0.0] - 2016-11-17 95 | - Commit first stable release 96 | 97 | ## v0.0.1 - 2016-11-17 98 | - Tag first release 99 | 100 | [v10.1.0]: https://github.com/rinvex/laravel-authy/compare/v10.0.0...v10.1.0 101 | [v10.0.0]: https://github.com/rinvex/laravel-authy/compare/v9.1.0...v10.0.0 102 | [v9.1.0]: https://github.com/rinvex/laravel-authy/compare/v9.0.0...v9.1.0 103 | [v9.0.0]: https://github.com/rinvex/laravel-authy/compare/v8.0.1...v9.0.0 104 | [v8.0.1]: https://github.com/rinvex/laravel-authy/compare/v8.0.0...v8.0.1 105 | [v8.0.0]: https://github.com/rinvex/laravel-authy/compare/v7.1.0...v8.0.0 106 | [v7.1.0]: https://github.com/rinvex/laravel-authy/compare/v7.0.0...v7.1.0 107 | [v7.0.0]: https://github.com/rinvex/laravel-authy/compare/v6.0.1...v7.0.0 108 | [v6.0.1]: https://github.com/rinvex/laravel-authy/compare/v6.0.0...v6.0.1 109 | [v6.0.0]: https://github.com/rinvex/laravel-authy/compare/v5.1.0...v6.0.0 110 | [v5.1.0]: https://github.com/rinvex/laravel-authy/compare/v5.0.0...v5.1.0 111 | [v5.0.0]: https://github.com/rinvex/laravel-authy/compare/v4.0.1...v5.0.0 112 | [v4.0.1]: https://github.com/rinvex/laravel-authy/compare/v4.0.0...v4.0.1 113 | [v4.0.0]: https://github.com/rinvex/laravel-authy/compare/v3.0.1...v4.0.0 114 | [v3.0.1]: https://github.com/rinvex/laravel-authy/compare/v3.0.0...v3.0.1 115 | [v3.0.0]: https://github.com/rinvex/laravel-authy/compare/v2.0.1...v3.0.0 116 | [v2.0.1]: https://github.com/rinvex/laravel-authy/compare/v2.0.0...v2.0.1 117 | [v2.0.0]: https://github.com/rinvex/laravel-authy/compare/v1.0.0...v2.0.0 118 | [v1.0.0]: https://github.com/rinvex/laravel-authy/compare/v0.0.1...v1.0.0 119 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Rinvex Authy 2 | 3 | This package is just a Laravel wrapper for [`rinvex/authy`](https://github.com/rinvex/authy). 4 | 5 | **Rinvex Authy** is a simple wrapper for Authy TOTP API, the best rated Two-Factor Authentication service for consumers, simplest 2fa Rest API for developers and a strong authentication platform for the enterprise. 6 | 7 | [![Packagist](https://img.shields.io/packagist/v/rinvex/laravel-authy.svg?label=Packagist&style=flat-square)](https://packagist.org/packages/rinvex/laravel-authy) 8 | [![Scrutinizer Code Quality](https://img.shields.io/scrutinizer/g/rinvex/laravel-authy.svg?label=Scrutinizer&style=flat-square)](https://scrutinizer-ci.com/g/rinvex/laravel-authy/) 9 | [![Travis](https://img.shields.io/travis/rinvex/laravel-authy.svg?label=TravisCI&style=flat-square)](https://travis-ci.org/rinvex/laravel-authy) 10 | [![StyleCI](https://styleci.io/repos/73999588/shield)](https://styleci.io/repos/73999588) 11 | [![License](https://img.shields.io/packagist/l/rinvex/laravel-authy.svg?label=License&style=flat-square)](https://github.com/rinvex/laravel-authy/blob/develop/LICENSE) 12 | 13 | ![Rinvex Authy](https://rinvex.com/assets/frontend/layout/img/products/rinvex-authy.png "Rinvex Authy") 14 | 15 | 16 | ## Table Of Contents 17 | 18 | - [Usage](#usage) 19 | - [Installation](#installation) 20 | - [Upgrade](#upgrade) 21 | - [Changelog](#changelog) 22 | - [Support](#support) 23 | - [Contributing & Protocols](#contributing--protocols) 24 | - [Security Vulnerabilities](#security-vulnerabilities) 25 | - [About Rinvex](#about-rinvex) 26 | - [Trademarks](#trademarks) 27 | - [License](#license) 28 | 29 | 30 | ## Usage 31 | 32 | Usage is pretty easy and straightforward: 33 | 34 | ### Authy App 35 | 36 | Get Authy app instance and interact with it: 37 | 38 | ```php 39 | $authyApp = app('rinvex.authy.app'); 40 | $appStats = $authyApp->stats(); // Get app stats 41 | $appDetails = $authyApp->details(); // Get app details 42 | ``` 43 | 44 | ### Authy User 45 | 46 | Get Authy user instance and interact with it: 47 | 48 | ```php 49 | $authyUser = app('rinvex.authy.user'); 50 | $user = $authyUser->register('user@domain.com', '317-338-9302', '54'); // Register user 51 | $userActivity = $authyUser->registerActivity($user->get('user')['id'], 'cookie_login', 'Test Data'); // Register user activity 52 | $userStatus = $authyUser->status($user->get('user')['id']); // Get user status 53 | $userDeleted = $authyUser->delete($user->get('user')['id']); // Delete user 54 | ``` 55 | 56 | ### Authy Token 57 | 58 | Get Authy token instance and interact with it: 59 | 60 | ```php 61 | $authyToken = app('rinvex.authy.token'); 62 | $smsTokenSent = $authyToken->send($user->get('user')['id'], 'sms'); // Send SMS token 63 | $callTokenStarted = $authyToken->send($user->get('user')['id'], 'call'); // Start automated call 64 | $tokenVerified = $authyToken->verify(54321, $user->get('user')['id']); // Verify token 65 | ``` 66 | 67 | ### Intuitive Responses 68 | 69 | Work Intuitively with Authy responses: 70 | 71 | ```php 72 | $body = $tokenVerified->body(); // Get all response body 73 | $code = $tokenVerified->statusCode(); // Get response status code 74 | $succeed = $tokenVerified->succeed(); // Check whether respose is a success 75 | $failed = $tokenVerified->failed(); // Check whether respose is a failure 76 | $message = $tokenVerified->message(); // Get response message 77 | $item = $tokenVerified->get('item'); // Get response body item 78 | $errors = $tokenVerified->errors(); // Get response errors 79 | ``` 80 | 81 | > **Note:** All authy requests return authy response, with a unified interface for your convenience, so you can interact with all responses the same way as above. 82 | 83 | 84 | ## Installation 85 | 86 | 1. Install the package via composer: 87 | ```shell 88 | composer require rinvex/laravel-authy 89 | ``` 90 | 91 | 2. If you don't have the following lines already, add them to your `config/services.php` file, before the end of the array: 92 | 93 | ```php 94 | 'authy' => [ 95 | 'secret' => env('AUTHY_SECRET'), 96 | ], 97 | ``` 98 | 99 | 3. If you haven't already: Register an [Authy](https://www.authy.com) account -> Sign in -> Access [dashboard](https://dashboard.authy.com) -> Create new application -> Copy your API Secret key 100 | 101 | 4. If you don't have the following lines already, add them to your project's `.env` file, at the end: 102 | 103 | ```ini 104 | AUTHY_SECRET=AuthySecretKey 105 | ``` 106 | 107 | > **Note:** make sure to replace `AuthySecretKey` with your key from the previous step. 108 | 109 | 5. Done! You can refer to [Usage](#usage) again. 110 | 111 | 112 | ## Upgrade 113 | 114 | - **Upgrading To `v2.x` From `v1.x`** 115 | 116 | API implementation is 100% backward compatible, but sandbox API has been dropped since it's officially deprecated. Also note that PHP7 is now required. Lastly the config options has been changed from `services.authy.mode`, `services.authy.keys.production`, and `services.authy.keys.sandbox` to only one key `services.authy.secret` for ease of use and consistency, accordingly the environment variables `AUTHY_MODE`, `AUTHY_PRODUCTION_KEY`, and `AUTHY_SANDBOX_KEY` are replaced with only one environment variable `AUTHY_SECRET`. 117 | 118 | 119 | ## Changelog 120 | 121 | Refer to the [Changelog](CHANGELOG.md) for a full history of the project. 122 | 123 | 124 | ## Support 125 | 126 | The following support channels are available at your fingertips: 127 | 128 | - [Chat on Slack](https://bit.ly/rinvex-slack) 129 | - [Help on Email](mailto:help@rinvex.com) 130 | - [Follow on Twitter](https://twitter.com/rinvex) 131 | 132 | 133 | ## Contributing & Protocols 134 | 135 | Thank you for considering contributing to this project! The contribution guide can be found in [CONTRIBUTING.md](CONTRIBUTING.md). 136 | 137 | Bug reports, feature requests, and pull requests are very welcome. 138 | 139 | - [Versioning](CONTRIBUTING.md#versioning) 140 | - [Pull Requests](CONTRIBUTING.md#pull-requests) 141 | - [Coding Standards](CONTRIBUTING.md#coding-standards) 142 | - [Feature Requests](CONTRIBUTING.md#feature-requests) 143 | - [Git Flow](CONTRIBUTING.md#git-flow) 144 | 145 | 146 | ## Security Vulnerabilities 147 | 148 | If you discover a security vulnerability within this project, please send an e-mail to [help@rinvex.com](help@rinvex.com). All security vulnerabilities will be promptly addressed. 149 | 150 | 151 | ## About Rinvex 152 | 153 | Rinvex is a software solutions startup, specialized in integrated enterprise solutions for SMEs established in Alexandria, Egypt since June 2016. We believe that our drive The Value, The Reach, and The Impact is what differentiates us and unleash the endless possibilities of our philosophy through the power of software. We like to call it Innovation At The Speed Of Life. That’s how we do our share of advancing humanity. 154 | 155 | 156 | ## Trademarks 157 | 158 | - [Authy™](https://www.authy.com) is a trademark of [Twilio Inc.](https://www.twilio.com) 159 | - [Laravel™](https://laravel.com) is a trademark of [TAYLOR OTWELL](http://taylorotwell.com) 160 | 161 | 162 | ## License 163 | 164 | This software is released under [The MIT License (MIT)](LICENSE). 165 | 166 | (c) 2016-2022 Rinvex LLC, Some rights reserved. 167 | --------------------------------------------------------------------------------