krak/doctrine-oauth2 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

krak/doctrine-oauth2

Composer 安装命令:

composer require krak/doctrine-oauth2

包简介

Doctrine and Laravel OAuth2 Integration

README 文档

README

This library provides OAuth2 integration for Doctrine and Laravel. It uses the league/oauth2-server package for all of the heavy lifting and the Doctrine ORM for the backend.

Installation

Install with composer at krak/doctrine-oauth2

Laravel Usage

<?php

$app = new Laravel\Lumen\Application(__DIR__ . '/..');

$app->register(LaravelDoctrine\ORM\DoctrineServiceProvider::class);
$app->register(LaravelDoctrine\Migrations\MigrationsServiceProvider::class);
$app->register(Krak\DoctrineOAuth2\OAuth2ServiceProvider::class);

$app['oauth2.seeds']->push(function($em, $logger) {
    $scopes = [
        new Scope('basic', 'Basic', 'Allows basic access to the API.'),
        new Scope('user', 'User', 'Allows user access to the API.'),
    ];

    $logger->info("Creating local client");
    $client = new Client('local', 'local', 'local123', '', $scopes);
    $em->persist($client);
    foreach ($scopes as $scope) {
        $logger->info("Creating scope: ". json_encode($scope, JSON_PRETTY_PRINT));
        $em->persist($scope);
    }
});

$app->router->group(['middleware' => 'oauth2'], function($router) {
    $router->get('/', function(Illuminate\Http\Request $req) {
        return $req->attributes->all();
    });
});
<?php

// config/oauth2.php

return [
    'grants' => [
        'refresh_token',
        'password',
        'client_credentials',
        'authorization_code',
        'implicit'
    ],
    'client_credentials' => [
        'access_token_ttl' => new DateInterval('P1Y'),
    ],
    'access_token_ttl' => new DateInterval('PT2H'),
    'refresh_token_ttl' => new DateInterval('P2Y'),
    'private_key' => resource_path('oauth-private.key'),
    'public_key' => resource_path('oauth-public.key'),
];

You need to run ./artisan oauth2:generate-keys to create the oauth keys. You can optionally run ./artisan oauth2:seed to run any seeds you may have defined for the oauth2 package.

统计信息

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

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-02-13

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固