定制 texthtml/oauth2-provider 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

texthtml/oauth2-provider

最新稳定版本:v1.5.1

Composer 安装命令:

composer require texthtml/oauth2-provider

包简介

OAuth2 provider for the Symfony Security component

README 文档

README

Build Status Latest Stable Version License Total Downloads Scrutinizer Code Quality

OAuth2 Provider is a provider for Symfony Security component that can be used to build OAuth2 protected applications

Installation

With Composer :

composer require texthtml/oauth2-provider

Usage with Silex 2

There is a Pimple provider you can use to secure Silex apps. You need to install Silex 2: composer require silex/silex "^2.0"

$app = new Silex\Application;

$oAuth2Provider = new TH\OAuth2\Pimple\OAuth2ServerProvider;
$app['security.entry_point.api.oauth2.realm'] = 'My App';
$app->register($oAuth2Provider, [
    'oauth2_server.storage.client' => function () use ($config) {
        return new TH\OAuth2\Storage\Memory\ClientMemoryStorage([
            'NICE_DEV_CLIENT' => [
                'name' => 'Nice Dev Client',
                'redirect_uri' => 'http://..../my_oauth2_callback',
            ],
        ]);
    },
    'oauth2_server.storage.pdo_connection' => function(Application $app) {
        return new PDO('...');
    },
]);
$app->mount('/auth/', $oAuth2Provider);

$app['users.provider'] = [
    // raw password is foo
    'admin' => array('ROLE_ADMIN', '5FZ2Z8QIkA7UTZ4BYkoC+GsReLf569mSKDsfods6LYQ8t+a8EW9oaircfMpmaLbPBh4FOBiiFyLfuZmTSUwzZg=='),
];

$app->register(new Silex\Provider\SecurityServiceProvider, [
    'security.firewalls' => [
        'oauth.token' => [
            'pattern' => '^/auth/token',
            'security' => false,
        ],
        'oauth.authorize' => [
            'pattern' => '^/auth/authorize',
            'http' => true,
            'users' => $app['users.provider'],
        ],
        'api' => [
            'pattern' => '^/api',
            'stateless' => true,
            'oauth2' => true,
            'security' => true,
            'users' => $app['users.provider'],
        ],
    ],
]);

Usage with other frameworks

This package can be used with any framework using the Symfony Security component (eg: Symfony, Laravel, Silex, etc.). But the provider TH\OAuth2\Pimple\OAuth2ServerProvider only works for Silex 2. For other frameworks you'll have to manually register the services and mount the routes.

PRs for providers for such frameworks are welcome!

统计信息

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

GitHub 信息

  • Stars: 5
  • Watchers: 2
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-12-21