承接 media24si/simple-oauth2 相关项目开发

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

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

media24si/simple-oauth2

Composer 安装命令:

composer require media24si/simple-oauth2

包简介

Laravel 5 Simple OAuth2

README 文档

README

Laravel5 Simple OAuth2 Server Package

Software License

A very simple OAuth2 package to use in your Laravel5 app. The package is a wrapper around the oauth2-php library and is inspired by FOSOAuthServerBundle.

Current features:

TODO:

Install

Require this package with composer (Packagist) using the following command:

$ composer require media24si/simple-oauth2

Register the SimpleOAuth2ServiceProvider to the providers array in config/app.php

Media24si\SimpleOAuth2\SimpleOAuth2ServiceProvider::class,

Publish vendor files:

$ php artisan vendor:publish

Migrate your database

$ php artisan migrate

Create a route for generating tokens:

$ Route::any('/token', '\Media24si\SimpleOAuth2\Http\Controllers\TokenController@token');

If you want to use Authorization code or Implicit grant type add authore controller to rote:

Route::any('/authorize', ['middleware' => 'auth','uses' => '\Media24si\SimpleOAuth2\Http\Controllers\AuthorizeController@authorize']);

USAGE

Config

When you publish vendor files, the simpleoauth2.php config file will be copied to the config folder. Currently the only configuration options are:

  • a username field
  • a password field
  • additional conditions

SimpleOAuth2 uses Auth::attempt to authenticate users.

Middleware

The package comes with one middleware. To use it, you need to register app\Http\Kernel.php under $routeMiddleware

'oauth' => '\Media24si\SimpleOAuth2\Http\Middleware\SimpleOAuth2'

Then in your routes you can request a valid oauth2 token:

Route::get('/protected', ['middleware' => ['oauth'], function() { return 'Protected resource'; }]);

Because SimpleOAuth2 is using Laravel authentication package you can request an authenticated user with oauth:

Route::get('/protected', ['middleware' => ['oauth', 'auth'], function() { return 'Protected resource with valid user'; }]);

Artisan commands

oauth2:create-client

$ php artisan oauth2:create-client {client_name}

Create a new oauth2 client. For all options see help

$ php artisan help oauth2:create-client {client_name}

oauth2:list-clients

$ php artisan oauth2:list-clients

List all oauth2 clients.

Grant types

Authorization Code and Implicit

To use authorization code or implicit grant types you have to provide auth middleware so user can login. You can customize authorize by implementing your own action and view.

License

The MIT License (MIT). Please see License File for more information.

统计信息

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

GitHub 信息

  • Stars: 3
  • Watchers: 3
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-04-24