chubbyphp / chubbyphp-session-storageless
此包已被废弃且不再维护。没有建议的替代包。
mezzio-session 的无存储持久性适配器
dev-master / 1.0.x-dev
2020-09-26 06:15 UTC
Requires
- php: ^7.2
- mezzio/mezzio-session: ^1.2
- psr7-sessions/storageless: ^5.0
Requires (Dev)
- chubbyphp/chubbyphp-dev-helper: dev-master
- chubbyphp/chubbyphp-mock: ^1.4.2
- infection/infection: ^0.15
- laminas/laminas-diactoros: ^2.1
- laminas/laminas-stratigility: ^3.1
- mavimo/phpstan-junit: ^0.3
- php-coveralls/php-coveralls: ^2.2
- phploc/phploc: ^5.0
- phpstan/extension-installer: ^1.0.3
- phpstan/phpstan: ^0.12.3
- phpunit/phpunit: ^8.5.1
This package is auto-updated.
Last update: 2020-09-26 06:16:27 UTC
README
描述
psr7-sessions/storageless 是 mezzio/mezzio-session 的持久性适配器。
已弃用:请使用 storageless-mezzio-integration 代替。
要求
- php: ^7.2
- mezzio/mezzio-session: ^1.2
- psr7-sessions/storageless: ^5.0
安装
通过 Composer 作为 chubbyphp/chubbyphp-session-storageless 安装。
composer require chubbyphp/chubbyphp-session-storageless "^1.0"
使用
使用对称密钥 (hmac) 与 laminas-stratigility
生成密钥
openssl rand -base64 32
代码
<?php declare(strict_types=1); namespace App; use Chubbyphp\Session\Storageless\PSR7StoragelessSessionPersistence; use PSR7Sessions\Storageless\Http\SessionMiddleware as PSR7SessionMiddleware; use Mezzio\Session\SessionMiddleware as MezzioSessionMiddleware; use Laminas\Stratigility\MiddlewarePipe; $middlewarePipe = new MiddlewarePipe(); $middlewarePipe->pipe(PSR7SessionMiddleware::fromSymmetricKeyDefaults( 'JeIn7GmQJRkM4dP3T5ZfVcHk7rxyVoMzR1DptTIquFY=', 1200 )); $middlewarePipe->pipe(new MezzioSessionMiddleware(new PSR7StoragelessSessionPersistence()));
使用非对称密钥 (rsa) 与 laminas-stratigility
生成密钥
openssl genrsa -out signatureKey 512 openssl rsa -in signatureKey -out verificationKey -outform PEM -pubout
代码
<?php declare(strict_types=1); namespace App; use Chubbyphp\Session\Storageless\PSR7StoragelessSessionPersistence; use PSR7Sessions\Storageless\Http\SessionMiddleware as PSR7SessionMiddleware; use Mezzio\Session\SessionMiddleware as MezzioSessionMiddleware; use Laminas\Stratigility\MiddlewarePipe; $middlewarePipe = new MiddlewarePipe(); $middlewarePipe->pipe(PSR7SessionMiddleware::fromAsymmetricKeyDefaults( '-----BEGIN RSA PRIVATE KEY----- MIIBOgIBAAJBAKgrmaZQsaEXrlNahrSKzKwWOgEt0SSFlv+Onm94oWNfx7ghZ+Up cgTwFl+oNMa/AbpO2a6fTuj558/Z0SlWFdUCAwEAAQJBAKKrMf/ndDqv7mcgXMaM sDgRc+AqEnCybAIdUXHgDLRSolzH36lkg6/jrr8S1G/e7QdK2yvpVgaP/KH0zReo nMECIQDdXX1vtzxgX+zv8DTNHN3m0StHuJHGC0oaOsDOX06IZQIhAMJ7dGy8XUGy 39INUFBneNc0I4QKxG31jIs6tOe/MiixAiA9GJiORNx9HPygHIP2OIlmM0TmvqI9 LtB8/MpKKzPZoQIgGQfwtSoNSq5uFkf2ZVLb/77LL2x/WbO38heNPyKhnxECIH1T PbQ839hbekzuV+y8Me+JSUHgybVMg9BDzRXwON7f -----END RSA PRIVATE KEY-----', '-----BEGIN PUBLIC KEY----- MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAKgrmaZQsaEXrlNahrSKzKwWOgEt0SSF lv+Onm94oWNfx7ghZ+UpcgTwFl+oNMa/AbpO2a6fTuj558/Z0SlWFdUCAwEAAQ== -----END PUBLIC KEY-----', 1200 )); $middlewarePipe->pipe(new MezzioSessionMiddleware(new PSR7StoragelessSessionPersistence()));
版权
Dominik Zogg 2020