2017 © Pedro Peláez
 

library signature-php

HMAC-SHA authentication

image

philipbrown/signature-php

HMAC-SHA authentication

  • Friday, May 22, 2015
  • by philipbrown
  • Repository
  • 9 Watchers
  • 63 Stars
  • 16,929 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 22 Forks
  • 2 Open issues
  • 14 Versions
  • 8 % Grown

The README.md

Signature

A PHP 5.4+ port of the Signature ruby gem, (*1)

Build Status Code Coverage Scrutinizer Code Quality, (*2)

Installation

Add philipbrown/signature-php as a requirement to composer.json:, (*3)

$ composer require philipbrown/signature-php

What is HMAC-SHA authentication?

HMAC-SHA authentication allows you to implement very simple key / secret authentication for your API using hashed signatures., (*4)

Making a request

use PhilipBrown\Signature\Token;
use PhilipBrown\Signature\Request;

$data    = ['name' => 'Philip Brown'];
$token   = new Token('abc123', 'qwerty');
$request = new Request('POST', 'users', $data);

$auth = $request->sign($token);

$http->post('users', array_merge($auth, $data));

Authenticating a response

use PhilipBrown\Signature\Auth;
use PhilipBrown\Signature\Token;
use PhilipBrown\Signature\Guards\CheckKey;
use PhilipBrown\Signature\Guards\CheckVersion;
use PhilipBrown\Signature\Guards\CheckTimestamp;
use PhilipBrown\Signature\Guards\CheckSignature;
use PhilipBrown\Signature\Exceptions\SignatureException;

$auth  = new Auth('POST', 'users', $_POST, [
    new CheckKey,
    new CheckVersion,
    new CheckTimestamp,
    new CheckSignature
]);

$token = new Token('abc123', 'qwerty');

try {
    $auth->attempt($token);
}

catch (SignatureException $e) {
    // return 4xx
}

Changing the default HTTP request prefix

By default, this package uses auth_* in requests. You can change this behaviour when signing and and authenticating requests:, (*5)

// default, the HTTP request uses auth_version, auth_key, auth_timestamp and auth_signature
$request->sign($token);
// the HTTP request now uses x-version, x-key, x-timestamp and x-signature
$request->sign($token, 'x-');

If you changed the default, you will need to authenticate the request accordingly:, (*6)

$auth->attempt($token, 'x-');

The Versions

22/05 2015

dev-master

9999999-dev

HMAC-SHA authentication

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

by Philip Brown

authentication hmac-sha

30/04 2015

v5.1.2

5.1.2.0

HMAC-SHA authentication

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

by Philip Brown

authentication hmac-sha

27/04 2015

v5.1.1

5.1.1.0

HMAC-SHA authentication

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

by Philip Brown

authentication hmac-sha

15/04 2015

v5.0.1

5.0.1.0

HMAC-SHA authentication

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

by Philip Brown

authentication hmac-sha

15/04 2015

v5.1.0

5.1.0.0

HMAC-SHA authentication

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

by Philip Brown

authentication hmac-sha

14/04 2015

v5.0.0

5.0.0.0

HMAC-SHA authentication

  Sources   Download

MIT

The Requires

 

The Development Requires

by Philip Brown

authentication hmac-sha

12/04 2015

v4.0.0

4.0.0.0

HMAC-SHA authentication

  Sources   Download

MIT

The Requires

 

The Development Requires

by Philip Brown

authentication hmac-sha

09/04 2015

v3.0.3

3.0.3.0

HMAC-SHA authentication

  Sources   Download

MIT

The Requires

 

The Development Requires

by Philip Brown

authentication hmac-sha

01/04 2015

v3.0.2

3.0.2.0

HMAC-SHA authentication

  Sources   Download

MIT

The Requires

 

The Development Requires

by Philip Brown

authentication hmac-sha

01/04 2015

v3.0.1

3.0.1.0

HMAC-SHA authentication

  Sources   Download

MIT

The Requires

 

The Development Requires

by Philip Brown

authentication hmac-sha

05/10 2014

v3.0.0

3.0.0.0

HMAC-SHA authentication

  Sources   Download

MIT

The Requires

 

The Development Requires

by Philip Brown

authentication hmac-sha

04/10 2014

v2.0.0

2.0.0.0

HMAC-SHA authentication

  Sources   Download

MIT

The Requires

 

The Development Requires

by Philip Brown

authentication hmac-sha

25/06 2014

v1.0.1

1.0.1.0

Key / Secret authentication for your API

  Sources   Download

MIT

The Requires

  • php >=5.3.2

 

The Development Requires

by Philip Brown

api authentication

21/04 2014

v1.0.0

1.0.0.0

Key / Secret authentication for your API

  Sources   Download

MIT

The Requires

  • php >=5.3.2

 

The Development Requires

by Philip Brown

api authentication