Package: matthisk_httpsig
Sign HTTP requests with secure signatures according to the IETF HTTP Signatures specification (Draft 3).  This is a fork of the originalmoduleto fully support both RSA and HMAC schemes as well as unit test both schemes to prove they work.  It’s being used in production and is actively-developed.See the originalproject, original Pythonmodule, originalspec, andcurrent IETF draftfor more details on the signing scheme.RequirementsPython 2.7, 3.2, 3.3, 3.4PyCryptoOptional:requestsUsageReal documentation is forthcoming, but for now this should get you started.For simple raw signing:importhttpsigsecret=open('rsa_private.pem','rb').read()sig_maker=httpsig.Signer(secret=secret,algorithm='rsa-sha256')sig_maker.sign('hello world!')For general use with web frameworks:importhttpsigkey_id="Some Key ID"secret=b'some big secret'hs=httpsig.HeaderSigner(key_id,secret,algorithm="hmac-sha256",headers=['(request-target)','host','date'])signed_headers_dict=hs.sign({"Date":"Tue, 01 Jan 2014 01:01:01 GMT","Host":"example.com"},method="GET",path="/api/1/object/1")For use with requests:importjsonimportrequestsfromhttpsig.requests_authimportHTTPSignatureAuthsecret=open('rsa_private.pem','rb').read()auth=HTTPSignatureAuth(key_id='Test',secret=secret)z=requests.get('https://api.example.com/path/to/endpoint',auth=auth,headers={'X-Api-Version':'~6.5'})Class initialization parametersNote that keys and secrets should be bytes objects.  At attempt will be made to convert them, but if that fails then exceptions will be thrown.httpsig.Signer(secret,algorithm='rsa-sha256')secret, in the case of an RSA signature, is a string containing private RSA pem. In the case of HMAC, it is a secret password.algorithmis one of the six allowed signatures:rsa-sha1,rsa-sha256,rsa-sha512,hmac-sha1,hmac-sha256,hmac-sha512.httpsig.requests_auth.HTTPSignatureAuth(key_id,secret,algorithm='rsa-sha256',headers=None)key_idis the label by which the server system knows your RSA signature or password.headersis the list of HTTP headers that are concatenated and used as signing objects. By default it is the specification’s minimum, theDateHTTP header.secretandalgorithmare as above.TestsTo run tests:python setup.py testor:toxLicenseBoth this module and the originalmoduleare licensed under the MIT license.httpsig Changes1.1.2 (2015-Feb-11)HMAC verification is now constant-time.1.1.1 (2015-Feb-11)(pulled)1.1.0 (2014-Jul-24)Changed “(request-line)” to “(request-target)” to comply with Draft 3.1.0.3 (2014-Jul-09)Unified the default signing algo under one setting. Setting httpsig.sign.DEFAULT_SIGN_ALGORITHM changes it for all future instances.Handle invalid params a little better.1.0.2 (2014-Jul-02)Ensure we treat headers as ASCII strings.Handle a case in the authorization header where there’s garbage (non-keypairs) after the method name.1.0.1 (2014-Jul-02)Python 3 support (2.7 + 3.2-3.4)Updated tox and Travis CI configs to test the supported Python versions.Updated README.1.0.0 (2014-Jul-01)Written againsthttp://tools.ietf.org/html/draft-cavage-http-signatures-02Added “setup.py test” and tox support.Added sign/verify unit tests for all currently-supported algorithms.HeaderSigner and HeaderVerifier now share the same message-building logic.The HTTP method in the message is now properly lower-case.Resolved unit test failures.Updated Verifier and HeaderVerifier to handle verifying both RSA and HMAC sigs.Updated versioneer.Updated contact/author info.Removed stray keypair in test dir.Removed SSH agent support.Removed suport for reading keyfiles from disk as this is a huge security hole if this is used in a server framework like drf-httpsig.1.0b1 (2014-Jun-23)Removed HTTP version from request-line, per spec (breaks backwards compatability).Removed auto-generation of missing Date header (ensures client compatability).http-signature (previous)0.2.0 (unreleased)Update to newer spec (incompatible with prior version).Handlerequest-linemeta-header.Allow secret to be a PEM encoded string.Add test cases from spec.0.1.4 (2012-10-03)Account for ssh now being re-merged into paramiko: either package is acceptable (but paramiko should ideally be >= 1.8.0)0.1.3 (2012-10-02)Stop enablingallow_agentby defaultStop requiringsshpackage by default – it is imported only whenallow_agent=TrueChanged logic around ssh-agent: if one key is available, don’t bother with any other authentication methodChanged logic around key file usage: if decryption fails, prompt for passwordBug fix: ssh-agent resulted in a nonsensical error if it found no correct keys (thanks, petervolpe)Introduce versioneer.py