pip install httpie-asap-auth
You should now see asap
and asapenv
under --auth-type
in the $ http --help
output.
http --auth-type=asap --auth=path/to/asap.config http://example.com/
OR, to read from environment variables:
http --auth-type=asapenv --auth=audience[:subject] http://example.com/
Separate multiple audiences with a comma.
Store your ASAP config in a file following this format:
{
"issuer": "webapp/admin",
"kid": "webapp/admin/dev.pem",
"audience": [
"webapp"
],
"sub": "administration",
"privateKey": "-----BEGIN RSA PRIVATE KEY-----\n ... \n-----END RSA PRIVATE KEY-----"
}
NB. the subject (sub
field) is optional.
ASAP_PRIVATE_KEY=data:application/pkcs8;kid=webapp;base64,...
ASAP_ISSUER=webapp/admin
Generate a data URI, with the key in PKCS8 from an RSA private key PEM file:
#!/bin/sh
# Usage: $0 privatekey.pem
KID=$(echo "$1" | sed 's|/|%2F|g')
KEY=$(openssl pkcs8 -topk8 -inform PEM -outform DER -in "$1" -nocrypt | base64 | tr '\n' ' ' | sed 's| ||g')
echo "data:application/pkcs8;kid=$KID;base64,$KEY"
(thanks to Brian McKenna)