ASAP Auth plugin for HTTPie.
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
tests
.gitignore
.pre-commit-config.yaml
.travis.yml
LICENSE
Makefile
README.md
httpie_asap_auth.py
setup.cfg
setup.py
test_requirements.txt
tox.ini

README.md

httpie-asap-auth

PyPi Package PyPi Versions Build Status Coverage Status Code style: black

ASAP Auth plugin for HTTPie.

Installation

$ pip install httpie-asap-auth

You should now see asap and asapenv under --auth-type in the $ http --help output.

Usage

$ 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.

Example ASAP Config

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.

Example Environment Variables

ASAP_PRIVATE_KEY=data:application/pkcs8;kid=webapp;base64,...
ASAP_ISSUER=webapp/admin

Generate a Data URI

Generate a data URI, with the key in PKCS8 from an RSA private key PEM file:

#!/bin/sh

# Usage: convert-pem-to-asap-data-uri.sh 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)