zacharyrankin / hmac-auth
Simple token authentication for PHP
v0.2
2015-06-13 20:18 UTC
Requires (Dev)
- phpunit/phpunit: ~4.7
This package is not auto-updated.
Last update: 2025-02-15 20:15:20 UTC
README
Simple token authentication for PHP
Usage
Require via Composer
composer require zacharyrankin/hmac-auth
Client
use zacharyrankin\hmac_auth\Authenticator; use zacharyrankin\hmac_auth\Client; $auth = new Authenticator; $token = $auth->createToken(new Client('some user', 'user secret')); header('X-Authorization-Token: ' . $token);
Server
use zacharyrankin\hmac_auth\Authenticator; use zacharyrankin\hmac_auth\Client; $auth = new Authenticator $auth->authenticate( $_SERVER['HTTP_X_AUTHORIZATION_TOKEN'], function ($clientId) { return new Client($clientId, SomeModel::findSecret($clientId)); }, 300 // expiration in seconds );