PHP code example of ebidtech / simple-authentication

1. Go to this page and download the library: Download ebidtech/simple-authentication library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ebidtech / simple-authentication example snippets





$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'));