zacharyrankin / hmac-auth
Simple token authentication for PHP
Installs: 27
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 1
pkg:composer/zacharyrankin/hmac-auth
Requires (Dev)
- phpunit/phpunit: ~4.7
This package is not auto-updated.
Last update: 2025-10-11 23:32:47 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 );