10个版本
0.3.1 | 2024年7月15日 |
---|---|
0.2.1 | 2024年3月20日 |
0.1.6 | 2022年12月20日 |
0.1.5 | 2022年8月15日 |
0.1.1 | 2021年11月23日 |
在 密码学 中排名第160
每月下载量2,000次
46KB
920 代码行
truelayer-signing
Rust包用于生成和验证TrueLayer API请求签名。
// `Tl-Signature` value to send with the request.
let tl_signature = truelayer_signing::sign_with_pem(kid, private_key)
.method(Method::Post)
.path("/payouts")
.header("Idempotency-Key", idempotency_key)
.body(body)
.build_signer()
.sign()?;
查看完整示例。
先决条件
- OpenSSL(请参阅此处的说明)。
验证webhook
可以使用 verify_with_jwks
函数验证webhook Tl-Signature
头签名。
// `jku` field is included in webhook signatures
let jku = truelayer_signing::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)?;
let jwks = fetch_jwks(jku);
// jwks may be used directly to verify a signature
truelayer_signing::verify_with_jwks(jwks)
.method(Method::Post)
.path(path)
.headers(all_webhook_headers)
.body(body)
.build_verifier()
.verify(webhook_signature)?;
请参阅webhook服务器示例。
依赖项
~3.5–5MB
~97K SLoC