11httpsig
22=======
33
4- Sign HTTP requests with secure signatures. See the original project _, original Python module _, original spec _, and IETF draft _ for details.
4+ .. image :: https://travis-ci.org/ahknight/httpsig.svg?branch=master
5+ :target: https://travis-ci.org/ahknight/httpsig
6+
7+ .. image :: https://travis-ci.org/ahknight/httpsig.svg?branch=develop
8+ :target: https://travis-ci.org/ahknight/httpsig
9+
10+ Sign HTTP requests with secure signatures according to the current IETF HTTP Signatures draft _ specification. This is a fork of the original module _ to 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.
11+
12+ See the original project _, original Python module _, original spec _, and current IETF draft _ for more details on the signing scheme.
513
614.. _project : https://github.com/joyent/node-http-signature
715.. _module : https://github.com/zzsnzmn/py-http-signature
@@ -11,6 +19,7 @@ Sign HTTP requests with secure signatures. See the original project_, original P
1119Requirements
1220------------
1321
22+ * Python 2.7, 3.2, 3.3, 3.4
1423* PyCrypto _
1524
1625Optional:
@@ -23,22 +32,40 @@ Optional:
2332Usage
2433-----
2534
26- for simple raw signing::
35+ Real documentation is forthcoming, but for now this should get you started.
36+
37+ For simple raw signing:
38+
39+ .. code :: python
2740
2841 import httpsig
2942
30- secret = open('rsa_private.pem', 'r ').read()
43+ secret = open (' rsa_private.pem' , ' rb ' ).read()
3144
3245 sig_maker = httpsig.Signer(secret = secret, algorithm = ' rsa-sha256' )
3346 sig_maker.sign(' hello world!' )
3447
35- for use with requests::
48+ For general use with web frameworks:
49+
50+ .. code :: python
51+
52+ import httpsig
53+
54+ key_id = " Some Key ID"
55+ secret = b ' some big secret'
56+
57+ hs = httpsig.HeaderSigner(key_id, secret, algorithm = " hmac-sha256" , headers = [' (request-line)' , ' host' , ' date' ])
58+ signed_headers_dict = hs.sign({" Date" : " Tue, 01 Jan 2014 01:01:01 GMT" , " Host" : " example.com" }, method = " GET" , path = " /api/1/object/1" )
59+
60+ For use with requests:
61+
62+ .. code :: python
3663
3764 import json
3865 import requests
3966 from httpsig.requests_auth import HTTPSignatureAuth
4067
41- secret = open('rsa_private.pem', 'r ').read()
68+ secret = open (' rsa_private.pem' , ' rb ' ).read()
4269
4370 auth = HTTPSignatureAuth(key_id = ' Test' , secret = secret)
4471 z = requests.get(' https://api.example.com/path/to/endpoint' ,
@@ -47,15 +74,18 @@ for use with requests::
4774 Class initialization parameters
4875~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4976
50- ::
77+ Note 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.
78+
79+ .. code :: python
5180
5281 httpsig.Signer(secret, algorithm = ' rsa-sha256' )
5382
5483 ``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.
5584``algorithm `` is one of the six allowed signatures: ``rsa-sha1 ``, ``rsa-sha256 ``, ``rsa-sha512 ``, ``hmac-sha1 ``, ``hmac-sha256 ``,
5685``hmac-sha512 ``.
5786
58- ::
87+
88+ .. code :: python
5989
6090 httpsig.requests_auth.HTTPSignatureAuth(key_id, secret, algorithm = ' rsa-sha256' , headers = None )
6191
@@ -70,7 +100,11 @@ To run tests::
70100
71101 python setup.py test
72102
103+ or::
104+
105+ tox
106+
73107License
74108-------
75109
76- MIT
110+ Both this module and the original module _ are licensed under the MIT license.
0 commit comments