2017 © Pedro Peláez
 

library http-signatures

Sign and verify HTTP messages

image

99designs/http-signatures

Sign and verify HTTP messages

  • Thursday, July 6, 2017
  • by mtibben
  • Repository
  • 31 Watchers
  • 24 Stars
  • 302,526 Installations
  • PHP
  • 4 Dependents
  • 0 Suggesters
  • 7 Forks
  • 5 Open issues
  • 23 Versions
  • 4 % Grown

The README.md

HTTP Signatures

PHP implementation of HTTP Signatures draft specification; allowing cryptographic signing and verifying of PSR7 messages., (*1)

See also:, (*2)

  • https://github.com/99designs/http-signatures-guzzlehttp
  • https://github.com/99designs/http-signatures-ruby

Usage

Add 99designs/http-signatures to your composer.json., (*3)

Configure a context with your algorithm, keys, headers to sign. This is best placed in an application startup file., (*4)

use HttpSignatures\Context;

$context = new Context([
  'keys' => ['examplekey' => 'secret-key-here'],
  'algorithm' => 'hmac-sha256',
  'headers' => ['(request-target)', 'Date', 'Accept'],
]);

If there's only one key in the keys hash, that will be used for signing. Otherwise, specify one via 'signingKeyId' => 'examplekey'., (*5)

Messages

A message is assumed to be a PSR-7 compatible request or response object., (*6)

Signing a message

$context->signer()->sign($message);

Now $message contains the signature headers:, (*7)

$message->headers->get('Signature');
// keyId="examplekey",algorithm="hmac-sha256",headers="...",signature="..."

$message->headers->get('Authorization');
// Signature keyId="examplekey",algorithm="hmac-sha256",headers="...",signature="..."

Verifying a signed message

$context->verifier()->isValid($message); // true or false

Symfony compatibility

Symfony requests normalize query strings which means the resulting request target can be incorrect. See https://github.com/symfony/psr-http-message-bridge/pull/30, (*8)

When creating PSR-7 requests you use withRequestTarget to ensure the request target is correct. For example, (*9)

use Symfony\Bridge\PsrHttpMessage\Factory\DiactorosFactory;
use Symfony\Component\HttpFoundation\Request;

$symfonyRequest = Request::create('/foo?b=1&a=2');
$psrRequest = (new DiactorosFactory())
    ->createRequest($symfonyRequest)
    ->withRequestTarget($symfonyRequest->getRequestUri());

Contributing

Pull Requests are welcome., (*10)

License

HTTP Signatures is licensed under The MIT License (MIT)., (*11)

The Versions

03/05 2017
19/01 2017

2.x-dev

2.9999999.9999999.9999999-dev

Sign and verify HTTP messages

  Sources   Download

MIT

The Requires

 

The Development Requires

https http signature signing hmac signed

19/01 2017

2.0.5

2.0.5.0

Sign and verify HTTP messages

  Sources   Download

MIT

The Requires

 

The Development Requires

https http signature signing hmac signed

17/10 2016

dev-stop-hinting-3rd-party-interface

dev-stop-hinting-3rd-party-interface

Sign and verify HTTP messages

  Sources   Download

MIT

The Requires

 

The Development Requires

https http signature signing hmac signed

02/07 2016

2.0.4

2.0.4.0

Sign and verify HTTP messages

  Sources   Download

MIT

The Requires

 

The Development Requires

https http signature signing hmac signed

04/05 2016

v2.0.3

2.0.3.0

Sign and verify HTTP messages

  Sources   Download

MIT

The Requires

 

The Development Requires

https http signature signing hmac signed

18/09 2015

v2.0.2

2.0.2.0 https://github.com/99designs/http-signatures-php

Sign and verify HTTP messages

  Sources   Download

MIT

The Requires

 

The Development Requires

https http signature signing hmac signed

18/09 2015

v1.1.2

1.1.2.0 https://github.com/99designs/http-signatures-php

Sign and verify HTTP messages

  Sources   Download

MIT

The Requires

 

The Development Requires

https http signature signing hmac signed

17/09 2015

v1.1.1

1.1.1.0 https://github.com/99designs/http-signatures-php

Sign and verify HTTP messages

  Sources   Download

MIT

The Requires

 

The Development Requires

https http signature signing hmac signed

17/09 2015

v2.0.1

2.0.1.0 https://github.com/99designs/http-signatures-php

Sign and verify HTTP messages

  Sources   Download

MIT

The Requires

 

The Development Requires

https http signature signing hmac signed

08/03 2015

v2.0.0

2.0.0.0 https://github.com/99designs/http-signatures-php

Sign and verify HTTP messages

  Sources   Download

MIT

The Requires

 

The Development Requires

https http signature signing hmac signed

06/08 2014

v1.1.0

1.1.0.0 https://github.com/99designs/http-signatures-php

Sign and verify HTTP messages

  Sources   Download

MIT

The Requires

 

The Development Requires

https http signature signing hmac signed

04/08 2014

v0.2.1

0.2.1.0 https://github.com/99designs/http-signatures-php

Sign and verify HTTP messages

  Sources   Download

MIT

The Requires

 

The Development Requires

https http signature signing hmac signed

04/08 2014

v1.0.0

1.0.0.0 https://github.com/99designs/http-signatures-php

Sign and verify HTTP messages

  Sources   Download

MIT

The Requires

 

The Development Requires

https http signature signing hmac signed

02/08 2014

v0.2.0

0.2.0.0 https://github.com/99designs/http-signatures-php

Sign and verify HTTP messages

  Sources   Download

MIT

The Requires

 

The Development Requires

https http signature signing hmac signed

31/07 2014

v0.1.0

0.1.0.0 https://github.com/99designs/http-signatures-php

Sign and verify HTTP messages

  Sources   Download

MIT

The Requires

 

The Development Requires

https http signature signing hmac signed