comes / simpleauthenticator
一个用于在Laravel中实现Google Authenticator双重认证(2FA)的PHP库,确保用户认证的安全性。
v2.0.0
2023-05-19 06:46 UTC
Requires
- php: ^8.1
- illuminate/contracts: ^10.0
Requires (Dev)
- laravel/pint: ^1.0
- nunomaduro/collision: ^7.9
- nunomaduro/larastan: ^2.0.1
- orchestra/testbench: ^8.0
- pestphp/pest: ^2.0
- pestphp/pest-plugin-arch: ^2.0
- pestphp/pest-plugin-laravel: ^2.0
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
This package is auto-updated.
Last update: 2024-09-09 05:58:39 UTC
README
SimpleAuthenticator包为Laravel应用提供了对Google Authenticator算法的直接实现。它可以根据提供的密钥轻松生成一次性密码(OTP)。
有关Google Authenticator算法的更多信息,请参阅RFC 6238或查看维基百科TOTP
使用方法
要使用SimpleAuthenticator,请通过提供密钥来创建SimpleAuthenticator类的实例。然后,您可以通过调用generate()
方法来生成一次性密码。
use Comes\SimpleAuthenticator\SimpleAuthenticator; $secret = 'YOUR_SECRET_KEY'; $authenticator = new SimpleAuthenticator; $oneTimePassword = $authenticator->generate($secret);
Laravel集成
SimpleAuthenticator包提供了一个用于生成OTP的Laravel命令。要使用它,您需要发布包配置并将密钥添加到配置文件中。
php artisan vendor:publish --provider="Comes\SimpleAuthenticator\SimpleAuthenticatorServiceProvider" --tag="config"
发布配置后,您可以将密钥添加到config/simpleauthenticator.php文件中。然后,您可以使用otp
命令为特定应用生成OTP。
php artisan otp app-name
测试
测试
您可以使用Pest运行测试。
composer test
composer test-coverage
变更日志
请参阅最新版本以获取有关最近更改的更多信息。
贡献
请参阅CONTRIBUTING以获取详细信息。
致谢
许可证
MIT许可证(MIT)。请参阅许可证文件以获取更多信息。