2017 © Pedro Peláez
 

library service-signature

A simple signature package of Laravel 5.3 for calling different services in a big system.

image

uicosp/service-signature

A simple signature package of Laravel 5.3 for calling different services in a big system.

  • Monday, February 6, 2017
  • by uicosp
  • Repository
  • 1 Watchers
  • 0 Stars
  • 188 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

服务签名 for Laravel 5.3

安装

composer require uicosp/service-signature, (*1)

然后在 config/app.phpproviders 数组中添加, (*2)

Uicosp\ServiceSignature\ServiceSignatureProvider::class

此扩展包含一个签名静态类用于签名和一个验证签名的中间件, (*3)

签名

Signature::genArray($service, array $query=[]);, (*4)

  • $service 需要调用的服务,根据此参数从配置文件查找对应的 service_keyservice_secret
  • $query 传递的 url 参数

返回签名后的 query 数组。示例:, (*5)

return Signature::genArray('cas', $query = [
            'foo' => 'bar',
        ]);

将返回:, (*6)

array:5 [
  "foo" => "bar"
  "service_key" => "caskey"
  "timestamp" => 1484029429
  "nonce" => "0SBliH0vT4"
  "signature" => "de203eac8b2cec03ac404ec3ed6d5bcd"
]

如果你希望直接返回 http_build_query 后的字符串,可调用 Signature::genString($service, array $query=[]),则如上示例将返回:, (*7)

"foo=bar&service_key=caskey&timestamp=1484029666&nonce=YkQFuVQFMU&signature=773c3d14c082b7a0ab14dcb2f9c471bf"

验证签名(中间件)

app/Http/Kernel.php 文件中注册 Uicosp\ServiceSignature\VerifySignature::class, 并对需要验证签名的路由添加本中间件。, (*8)

The Versions

06/02 2017

dev-master

9999999-dev

A simple signature package of Laravel 5.3 for calling different services in a big system.

  Sources   Download

MIT

06/02 2017

1.0.3

1.0.3.0

A simple signature package of Laravel 5.3 for calling different services in a big system.

  Sources   Download

MIT

06/02 2017

dev-dev

dev-dev

A simple signature package of Laravel 5.3 for calling different services in a big system.

  Sources   Download

MIT

11/01 2017

1.0.2

1.0.2.0

A simple signature package of Laravel 5.3 for calling different services in a big system.

  Sources   Download

MIT

10/01 2017

1.0.1

1.0.1.0

A simple signature package of Laravel 5.3 for calling different services in a big system.

  Sources   Download

MIT

10/01 2017

1.0.0

1.0.0.0

A simple signature package of Laravel 5.3 for calling different services in a big system.

  Sources   Download

MIT