PHPackages                             chervand/yii2-oauth2-server - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. chervand/yii2-oauth2-server

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

chervand/yii2-oauth2-server
===========================

OAuth 2.0 server for Yii 2.0 with MAC tokens support.

0.8.2(5y ago)1524.2k↓42.3%15[3 issues](https://github.com/chervand/yii2-oauth2-server/issues)1MITPHPPHP &gt;=5.6.0

Since Sep 27Pushed 4y ago3 watchersCompare

[ Source](https://github.com/chervand/yii2-oauth2-server)[ Packagist](https://packagist.org/packages/chervand/yii2-oauth2-server)[ RSS](/packages/chervand-yii2-oauth2-server/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (6)Dependencies (4)Versions (18)Used By (1)

Yii 2.0 OAuth 2.0 Server
========================

[](#yii-20-oauth-20-server)

`chervand/yii2-oauth2-server` is a `Yii 2.0 PHP Framework` integration of [`thephpleague/oauth2-server`](https://github.com/thephpleague/oauth2-server) library which implements a standards compliant [`OAuth 2.0 Server`](https://tools.ietf.org/html/rfc6749) for PHP. It supports all of the grants defined in the specification with usage of `JWT` `Bearer` tokens.

`chervand/yii2-oauth2-server` additionally provides [`MAC`](https://tools.ietf.org/html/draft-ietf-oauth-v2-http-mac-05) tokens support, which is not supported by the original library, because `MAC` tokens specification is currently in draft and it was not updated since 2014, so it's a pretty experimental feature.

It also includes tokens revocation implementation based on [RFC7009](https://tools.ietf.org/html/rfc7009).

Installation
------------

[](#installation)

### Applying DB migrations

[](#applying-db-migrations)

```
./yii migrate --migrationPath="@vendor/chervand/yii2-oauth2-server/migrations"

```

### Generating public and private keys

[](#generating-public-and-private-keys)

See [OAuth 2.0 Server installation](https://oauth2.thephpleague.com/installation/) page.

### Integrating with your users

[](#integrating-with-your-users)

To integrate OAuth 2.0 server with your users DB, you should implement `League\OAuth2\Server\Repositories\UserRepositoryInterface` for a `user` component's `identityClass` which should be extended from `chervand\yii2\oauth2\server\models\AccessToken`. `League\OAuth2\Server\Repositories\UserRepositoryInterface::getUserEntityByUserCredentials()` should return your user model instance implementing `League\OAuth2\Server\Entities\UserEntityInterface` or `null`. You may additionally add a foreign key for the `auth__access_token.user_id` column referencing your users table. You mau also override `getRateLimit()` to provider ` yii\filters\RateLimitInterface` with required values.

```
