truelayer/signing
Composer 安装命令:
composer require truelayer/signing
包简介
Produce and verify TrueLayer API requests signatures
关键字:
README 文档
README
PHP library to produce & verify TrueLayer API request signatures. If you want to know more about how TrueLayer's signatures work, see this documentation for an explanation.
Installation
Require using composer:
$ composer require truelayer/signing
Usage
Signing
First, create a Signer instance, using one of the following methods:
use TrueLayer\Signing\Signer; $signer = Signer::signWithPemFile('kid-value', '/path/to/privatekey'); $signer = Signer::signWithPem('kid-value', $pemContents); $signer = Signer::signWithPemBase64('kid-value', $pemContentsBase64Encoded); $signer = Signer::signWithKey('kid-value', new \Jose\Component\Core\JWK());
Then you can use it to create signatures:
use TrueLayer\Signing\Signer; $signature = $signer->method('POST') ->path('/path') // The api path ->header('Idempotency-Key', 'my-key') // The idempotency key you must send with your request ->body('stringified request body') ->sign();
You can also sign a PSR-7 request which will automatically compile the signature and add it to the Tl-Signature
header.
use TrueLayer\Signing\Signer; $request = $signer->addSignatureHeader($request)
Verifying
First, retrieve the public keys:
- for sandbox: https://webhooks.truelayer-sandbox.com/.well-known/jwks
- for production: https://webhooks.truelayer.com/.well-known/jwks
Example using the Guzzle library:
use TrueLayer\Signing\Verifier; use GuzzleHttp\Client; // Note: you should add error handling as appropriate $httpClient = new Client(); $response = $httpClient->get('https://webhooks.truelayer-sandbox.com/.well-known/jwks')->getBody()->getContents(); $keys = json_decode($response, true)['keys']; $verifier = Verifier::verifyWithJsonKeys(...$keys); // Note the spread operator, it's important.
Then you can use it to verify the signature you receive in your webhook under the tl-signature header:
$verifier ->path('/path') // Should be your webhook path, for example $_SERVER['REQUEST_URI'] ->headers($headers) // All headers you receive. Header names can be in any casing. ->body('stringified request body'); // For example file_get_contents('php://input'); try { $verifier->verify($headers['tl-signature']); } catch (InvalidSignatureException $e) { throw $e; // Handle invalid signature. You should not use this request's data. }
truelayer/signing 适用场景与选型建议
truelayer/signing 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 216.99k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2021 年 12 月 10 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「signing」 「JWS」 「truelayer」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 truelayer/signing 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 truelayer/signing 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 truelayer/signing 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
BitWeb extension for Estonian ID-Card and Mobile ID authentication and signing.
A library to work with JSON Web Token and JSON Web Signature.
PHP Secure Communications Library - Pure-PHP implementations of RSA, AES, SSH2, SFTP, X.509 etc.
Laravel-first JWT and JWS support with profile-driven issuance and validation
PHP Secure Communications Library - Pure-PHP implementations of RSA, AES, SSH2, SFTP, X.509 etc.
This Bundle provides full authentication for login form and also Api with JWS (signed JWT 'encrypted with OpenSSL encryption engine') based on Symfony Guard
统计信息
- 总下载量: 216.99k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 14
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-12-10