francodacosta/caparica
最新稳定版本:1.0
Composer 安装命令:
composer require francodacosta/caparica
包简介
secure your REST api with signed requests
README 文档
README
Php library to validate and create signed requests
this is a low level library, you might want to check
- Caparica Bundle a symfony2 bundle
- Caparica Guzzle a Guzzle plugin to automatically sign requests for you
Installation
composer.phar require francodacosta/caparica
Documentation
Please be sure to read the documentation, make sure you understand the client and server parts of Caparica.
The latest documentation can be found on the docs folder
Sign a request (client side)
use Caparica\Crypto\RequestSigner; $signer = new RequestSigner(); $password = "12345678901234567890"; $params = array ( 'a' => 'bcd', 'c' => '123', 'b' => 'ewq', 'X-CAPARICA-TIMESTAMP' => date('U') ); $signature = $signer->sign($params, $password);
Validate a request (server side)
use Caparica\Security\RequestValidator; use Caparica\Client\BasicClient; $client = new BasicClient; $requestValidator = new RequestValidator(new RequestSigner); // this values come from the request the client made // use whatever methods your framework has to access http requests $requestParams = array( 'X-CAPARICA-DATE' => "12345676743", 'a' => 'bcd', 'c' => '123', 'b' => 'ewq', ); // the signature comes from the request, we will use it to compare with the server // generated one, if they match we know the request is valid $requestSignature = '0c6513e432bb25d8be659a99ca240a64f60dee875e04d557341a677bfe08a1bf'; $isValid = $requestValidator->validate($client, $requestSignature, $requestParams);
统计信息
- 总下载量: 35.69k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 2
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2013-12-12