maksimovic/slim-oauth2-middleware
Composer 安装命令:
composer require maksimovic/slim-oauth2-middleware
包简介
OAuth2 middleware for use within a Slim Framework API
关键字:
README 文档
README
Fork Notice: This is a maintained fork of the abandoned
chadicus/slim-oauth2-middlewarepackage. Updated for PHP 8.1+ and PSR-15.
PSR-15 middleware for using OAuth2 Server within any PSR-15 compatible framework, including Slim 4.
Requirements
PHP 8.1 or later.
Installation
composer require maksimovic/slim-oauth2-middleware
Example usage
use Chadicus\Slim\OAuth2\Middleware\Authorization; use OAuth2; use OAuth2\Storage; use OAuth2\GrantType; $storage = new Storage\Memory([ 'client_credentials' => [ 'administrator' => ['client_id' => 'administrator', 'client_secret' => 'password', 'scope' => 'superUser'], ], ]); $server = new OAuth2\Server( $storage, ['access_lifetime' => 3600], [new GrantType\ClientCredentials($storage)] ); $auth = new Authorization($server, $container); // Slim 4 $app->get('/foos', $handler)->add($auth); $app->post('/foos', $handler)->add($auth->withRequiredScope(['superUser']));
$container must be either an ArrayAccess or expose a set($key, $value) method (e.g. PHP-DI). The decoded access token is stored under the 'token' key on success and added to the request as the oauth2-token attribute.
Development
composer install
composer test
composer test:coverage
composer cs-check
License
MIT
统计信息
- 总下载量: 2.84k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 1
其他信息
- 授权协议: MIT
- 更新时间: 2026-03-13