承接 maksimovic/slim-oauth2-http 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

maksimovic/slim-oauth2-http

Composer 安装命令:

composer require maksimovic/slim-oauth2-http

包简介

Bridge components for PSR-7 and bshaffer's OAuth2 Server http messages.

README 文档

README

Fork Notice: This is a maintained fork of the abandoned chadicus/slim-oauth2-http package. Updated for PHP 8.1+ with support for laminas/laminas-diactoros v3.

Static utility classes to bridge PSR-7 HTTP messages to OAuth2 Server requests and responses. While this library is intended for use with Slim, it should work with any PSR-7 compatible framework.

Requirements

Installation

composer require maksimovic/slim-oauth2-http

Usage

Convert a PSR-7 request to an OAuth2 request

use Chadicus\Slim\OAuth2\Http\RequestBridge;

$oauth2Request = RequestBridge::toOAuth2($psrRequest);

Convert an OAuth2 response to a PSR-7 response

use Chadicus\Slim\OAuth2\Http\ResponseBridge;

$psr7Response = ResponseBridge::fromOAuth2($oauth2Response);

Example Integration

Simple route for creating a new OAuth2 access token

use Chadicus\Slim\OAuth2\Http\RequestBridge;
use Chadicus\Slim\OAuth2\Http\ResponseBridge;
use OAuth2;
use OAuth2\GrantType;
use OAuth2\Storage;
use Slim;

$storage = new Storage\Memory(
    [
        'client_credentials' => [
            'testClientId' => [
                'client_id' => 'testClientId',
                'client_secret' => 'testClientSecret',
            ],
        ],
    ]
);

$server = new OAuth2\Server(
    $storage,
    [
        'access_lifetime' => 3600,
    ],
    [
        new GrantType\ClientCredentials($storage),
    ]
);

$app = new Slim\App();

$app->post('/token', function ($psrRequest, $psrResponse, array $args) use ($app, $server) {
    // Create an \OAuth2\Request from the PSR-7 request
    $oauth2Request = RequestBridge::toOAuth2($psrRequest);

    // Let the OAuth2 server handle the request
    $oauth2Response = $server->handleTokenRequest($oauth2Request);

    // Map the OAuth2 response to a PSR-7 response
    return ResponseBridge::fromOAuth2($oauth2Response);
});

Development

composer install
composer test
composer test:coverage
composer cs-check

License

MIT

统计信息

  • 总下载量: 2.56k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 3
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 12
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-13

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固