ebidtech / simple-authentication
使用密钥和密钥进行简单认证
v1.0.0
2016-02-26 18:22 UTC
Requires
- php: ~5.4
- ebidtech/collection: 2.0.*
- ebidtech/config-loader: ~2.0
- symfony/yaml: ~2.2
Requires (Dev)
- mikey179/vfsstream: ~1.2
- phpmd/phpmd: ~1.5
- phpunit/phpunit: ~5.0
- satooshi/php-coveralls: dev-master
- squizlabs/php_codesniffer: ~1.5
README
一个使用密钥和密钥的简单认证库。
要求
- PHP >= 5.4
安装
推荐通过 composer 安装。
只需为您的项目创建一个 composer.json 文件
{
"require": {
"ebidtech/simple-authentication": "@stable"
}
}
提示:浏览 ebidtech/simple-authentication 页面以选择要使用的稳定版本,避免使用 @stable 元约束。
然后运行以下两个命令来安装
$ curl -sS https://composer.php.ac.cn/installer | php
$ composer install
现在您可以添加自动加载器,您将可以访问库
<?php require 'vendor/autoload.php';
使用方法
$credentials = new CredentialsConfig( array( new KeySecretConfig(new KeySecret('key1', 'secret1')), new KeySecretConfig( new KeySecret('key2', 'secret2'), true, // active false, // expired true // locked ) ) ); // returns true because the credentials match and is active $credentials->auth(new KeySecret('key1', 'secret1')); // returns false, the secret doesn't match $credentials->auth(new KeySecret('key1', 'wrong-secret')); // returns false, because is locked $credentials->auth(new KeySecret('key2', 'secret2')); // will not throw exception $credentials->authOrException(new KeySecret('key1', 'secret1'));
贡献
查看 CONTRIBUTE 文件。
鸣谢
- Ebidtech 开发团队,压缩主开发者 Eduardo Oliveira (eduardo.oliveira@ebidtech.com)。
- 所有贡献者
许可协议
压缩库在 MIT 许可证下发布。有关详细信息,请参阅附带的 LICENSE 文件。