Simple Authentication
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 installNow 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.




