originalmind/apiauth

Laravel 过滤器,用于通过 OAuth 实现常见的 API 授权任务。

0.1.2 2014-10-01 03:05 UTC

This package is not auto-updated.

Last update: 2024-09-24 02:32:03 UTC


README

一组过滤器,用于帮助保护 API 路由。目前仅支持来自 https://packagist.org.cn/packages/lucadegasperi/oauth2-server-laravel 包的 Resource Server 实现。

** 进行中!** 此包需要更多工作以使其通用。

安装

composer.json:

"require": {
	"originalmind/apiauth": "0.1.*"	
}

app/config/app.php:

将以下内容添加到您的服务提供者数组中

'OriginalMind\ApiAuth\ApiAuthServiceProvider',

在您的控制器构造函数中:

<?php

class MyController extends \BaseController {

	public function __construct() {
		// OAuth token checking - from an OAuth package
		$this->beforeFilter('oauth:admin', array('only' => array('index', 'destroy')));
		$this->beforeFilter('oauth:enduser', array('only' => array('show', 'update')));

		// Token owner checking - from this package
		$this->beforeFilter('apiauthuserowner:mymodel', array('only' => array('show', 'update')));
	}

?>