Produce & verify TrueLayer API requests signatures
Project description
truelayer-signing
Python package to produce & verify TrueLayer API requests signatures.
Install
pip install truelayer-signing
Generating a signature
tl_signature = sign_with_pem(KID, PRIVATE_KEY) \
.set_method(HttpMethod.POST) \
.set_path(path) \
.add_header("Idempotency-Key", idempotency_key) \
.set_body(body) \
.sign()
See full example.
Verifying webhooks
The verify_with_jwks
function may be used to verify webhook Tl-Signature
header signatures.
# `jku` field is included in webhook signatures
jws_header = extract_jws_header(webhook_signature).jku
# check `jku` is an allowed TrueLayer url & fetch jwks JSON (not provided by this lib)
ensure_jku_allowed(jku)
jwks = fetch_jwks(jku)
# jwks may be used directly to verify a signature
verify_with_jwks(jwks, jws_header) \
.set_method(HttpMethod.POST) \
.set_path(path) \
.add_headers(headers) \
.set_body(body) \
.verify(tl_signature)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
truelayer_signing-0.3.5.tar.gz
(11.4 kB
view hashes)
Built Distribution
Close
Hashes for truelayer_signing-0.3.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 03709457cc4e61cb61b3acf63ed0f109967ecf7888dd9a0ab4a0327d90faba19 |
|
MD5 | e7fff091c2ff14056b8e051eed95c003 |
|
BLAKE2b-256 | a8d09c20d593e7a5e83c0add39aa5e77cac2589e5d486e47966c17c6dffd7f5d |