ozanhazer/safe-link

使用过期日期签名URL,以在项目间传输数据

v1.0.0 2022-01-31 16:01 UTC

This package is auto-updated.

Last update: 2024-09-18 14:26:35 UTC


README

Unit Tests

框架无关、轻量级URL签名器。您可以使用SafeLink在项目间传输数据。

在项目1中签名url

use Alfatron\SafeLink;

$safelink = new SafeLink('my-not-short-private-key');
$safelink->redirect('https://second-project/path', ['user' => 'test@example.com', 'action' => 'feed the cat'])

在项目2中检索它

use Alfatron\SafeLink;

$safelink = new SafeLink('my-not-short-private-key');
$data = $safeLink->verify();
assert($data['user'], 'test@example.com');

功能

  • 使用内置的php序列化器将传输的数据序列化。
  • 可以传输任何可以序列化的php类型:objectarraystringinteger
  • 支持php 7.0+。
  • 默认超时时间为10秒(可自定义)。
  • 使用openssl扩展加密数据(AES-256 CBC

安装

运行composer require ozanhazer/safe-link即可!

选项

默认超时时间为10秒,以避免重放攻击。您可以通过以下方式更改它

use Alfatron\SafeLink;

$safeLink = new SafeLink($privateKey, ['timeout' => 2]);