east36 / httpie-http-signatures Goto Github PK
View Code? Open in Web Editor NEWHTTP Signatures (https://tools.ietf.org/html/draft-cavage-http-signatures-07) auth plugin for HTTPie
HTTP Signatures (https://tools.ietf.org/html/draft-cavage-http-signatures-07) auth plugin for HTTPie
I have attempted to install this package on a py3 environment and I think that it's dependency: httpsig_cffi.sign.HeaderSigner->generate_message is not outputting the correct signature in py3.
Additionally, the sign body block for POST & PUT is not py3 compatible (it concats bytes & strings). Here's the correct block
55 if sign_body:
56 body = request.body or ""
57 if "digest" not in request.headers:
58 m = hashlib.sha256(body.encode("utf-8"))
59 base64digest = base64.b64encode(m.digest())
60 base64string = base64digest.decode("utf-8")
61 request.headers["digest"] = 'SHA-256=' + base64string
Perhaps httpsig_cffi needs to be declared in setup.py?
❯ http --version
0.9.9
❯ pip install -U httpie-httpsig-auth
Collecting httpie-httpsig-auth
Using cached httpie-httpsig-auth-0.1.0.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/lmwangi/pip-build-_sAGel/httpie-httpsig-auth/setup.py", line 1, in <module>
import httpie_httpsig_auth
File "httpie_httpsig_auth.py", line 6, in <module>
import httpsig_cffi.sign
ImportError: No module named httpsig_cffi.sign
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/lmwangi/pip-build-_sAGel/httpie-httpsig-auth/
What is the correct syntax for making a POST request with JSON body
echo '{"hello": "world"}' | http POST http://localhost:8080/ --auth-type=httpsig --auth 'username:password'
http: error: AttributeError: 'bytes' object has no attribute 'encode'
Same above command working fine with other httpie plugins like ntlm oauth etc
GET WORKS FINE
http GET http://localhost:8080/ --auth-type=httpsig --auth 'username:password'
HTTP/1.1 200
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Content-Type: application/json;charset=UTF-8
Date: Fri, 10 Jul 2020 10:50:53 GMT
Expires: 0
Pragma: no-cache
Transfer-Encoding: chunked
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
X-XSS-Protection: 1; mode=block
{
"auth_details": "Signature keyId="username",algorithm="hmac-sha256",signature="bczfb2LsKFoqPxhx06r93QO122lR494e/9YsfeWg9yo=",headers="date (request-target) host"",
"body_info": null,
"host_info": "localhost:8080",
"id": 6,
"method_info": "GET",
"path_info": "/",
"protocol_info": "http",
"query_params": null
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.