ebidtech / simple-authentication
A simple authentication using key and secret
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
A simple authentication library using a key and secret.
Requirements
- PHP >= 5.4
Installation
The recommended way to install is through composer.
Just create a composer.json
file for your project:
{ "require": { "ebidtech/simple-authentication": "@stable" } }
Tip: browse ebidtech/simple-authentication
page to choose a stable version to use, avoid the @stable
meta constraint.
And run these two commands to install it:
$ curl -sS https://getcomposer.org/installer | php
$ composer install
Now you can add the autoloader, and you will have access to the library:
<?php require 'vendor/autoload.php';
Usage
$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'));
Contributing
See CONTRIBUTING file.
Credits
- Ebidtech developer team, compress Lead developer Eduardo Oliveira (eduardo.oliveira@ebidtech.com).
- All contributors
License
Compress library is released under the MIT License. See the bundled LICENSE file for details.