ebidtech/simple-authentication

A simple authentication using key and secret

Installs: 67

Dependents: 0

Stars: 1

Watchers: 14

Forks: 1

Language: PHP

v0.3 2014-02-01 12:25 UTC

README

A simple authentication library using a key and secret.

Latest Stable Version Build Status Coverage Status Scrutinizer Quality Score Dependency Status

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

License

Compress library is released under the MIT License. See the bundled LICENSE file for details.