php oauth2.0开源,GitHub - whisper540/phpAndOauth2.0: 基于CI框架的Oauth2.0搭建,修改于网友的开源代码,可以直接运行,运行前需要修改数据库配置,...

CodeIgniter OAuth2 Server

CodeIgniter OAuth2 Server, a CodeIgniter package for OAuth2.0 Server,

Installation

1.Clone pakcage

2.Config database -> $db['oauth']

cd codeigniter-oauth2-server

vim application/config/database.php

config dsn, hostname, username, password, database

3.Import database

mysqldump -u root -p > sql/oauth.sql

Usage

Password Credentials

class PasswordCredentials extends CI_Controller {

function __construct(){

@session_start();

parent::__construct();

$this->load->library("Server", "server");

$this->server->password_credentials();//credentials check here

}

function index(){

//code here

}

}

Client Credentials

class ClientCredentials extends CI_Controller {

function __construct(){

@session_start();

parent::__construct();

$this->load->library("Server", "server");

$this->server->client_credentials(); //credentials check here

}

function index(){

//code here

}

}

Refresh Token

class RefreshToken extends CI_Controller {

function __construct(){

@session_start();

parent::__construct();

$this->load->library("Server", "server");

}

function index(){

$this->server->refresh_token(); //refresh token

}

}

Get resource by OAuth2.0 authorize.

class Resource extends CI_Controller {

function __construct(){

@session_start();

parent::__construct();

$this->load->library("Server", "server");

$this->server->require_scope("userinfo cloud file node");//you can require scope here

}

public function index(){

//resource api controller

echo json_encode(array('success' => true, 'message' => 'You accessed my APIs!'));

}

}

More usage:

for more usage please see: application/controllers/Test.php

Features

Support for: Password Credentials, Client Credentials, Implicit Grant, Authorization Code grant types.

Refresh access token

From access token get resource data

Support for Mysql, Redis, Mongo

License

This library is under the MIT license. For the full copyright and license information, please view the LICENSE file that was distributed with this source code.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值