PHPackages                             ddruganov/yii2-api-auth-proxy - 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. ddruganov/yii2-api-auth-proxy

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

ddruganov/yii2-api-auth-proxy
=============================

Authentication proxy tools for yii2

0.2.3(4y ago)010PHP

Since Apr 17Pushed 4y ago1 watchersCompare

[ Source](https://github.com/ddruganov/yii2-api-auth-proxy)[ Packagist](https://packagist.org/packages/ddruganov/yii2-api-auth-proxy)[ RSS](/packages/ddruganov-yii2-api-auth-proxy/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (7)Versions (10)Used By (0)

yii2-api-auth-proxy
===================

[](#yii2-api-auth-proxy)

An authentication proxy component library that connects your app with the yii2-api-auth server

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

[](#installation)

`composer require ddruganov/yii2-api-auth-proxy`

Configuration
-------------

[](#configuration)

1. Add this to your app's main config:

```
...
    'components' => [
        AccessTokenProviderInterface::class => HeaderAccessTokenProvider::class,
        AuthServiceInterface::class => AuthService::class,
        AuthServiceRequestInterface::class => GuzzleAuthServiceRequest::class
    ],
    'controllerMap' => [
        'auth' => AuthController::class
    ],
...
```

2. Add this to your app's params config:

```
...
    'authentication' => [
        'externalService' => [
            'url' => 'https://server-that-has-yii2-api-auth-installed'
        ]
    ]
...
```

How to use
----------

[](#how-to-use)

- `POST /auth/login` with an access token that you got from logging in on the yii2-api-auth server to check that your log in is valid
- `POST /auth/refresh` with your refresh token to get a fresh pair of tokens form the main server
- `POST /auth/logout` to send a logout request to the main server
- Use `Yii::$app->get(AuthServiceInterface::class)->getUser()` to get the `ddruganov\Yii2ApiAuthProxy\components\AuthServiceUser`
- Attach `AuthFilter` as a behavior to your `ApiController` to only allow authenticated users to access the endpoints
- Attach `RbacFilter` as a behavior to your `ApiController` to only allow users with specific permissions to access the endpoints

### Extending `AuthServiceInterface::getUser()` example

[](#extending-authserviceinterfacegetuser-example)

```
class YourAuthService extends Yii2ApiAuthProxyAuthService
{
    public function getUser(string $accessToken): YourAuthServiceUser
    {
        $baseUrl = Yii::$app->params['authentication']['externalService']['url'];

        $result = Yii::$app->get(AuthServiceRequestInterface::class)->make(
            method: AuthServiceRequestInterface::GET,
            url: $baseUrl . '/' . self::CURRENT_USER_ENDPOINT,
            data: [],
            accessToken: $accessToken
        );

        if (!$result->isSuccessful()) {
            throw new Exception('Error getting user from a remote auth server');
        }

        return new YourAuthServiceUser($result->getData());
    }
}
```

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

9

Last Release

1491d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b68509a8d66d630b4f6a4faef3a5cb2cbea6b5c78321cc6940aa78554a95a27a?d=identicon)[ddruganov](/maintainers/ddruganov)

---

Top Contributors

[![ddruganov](https://avatars.githubusercontent.com/u/12191677?v=4)](https://github.com/ddruganov "ddruganov (11 commits)")

###  Code Quality

TestsCodeception

### Embed Badge

![Health badge](/badges/ddruganov-yii2-api-auth-proxy/health.svg)

```
[![Health](https://phpackages.com/badges/ddruganov-yii2-api-auth-proxy/health.svg)](https://phpackages.com/packages/ddruganov-yii2-api-auth-proxy)
```

###  Alternatives

[thenetworg/oauth2-azure

Azure Active Directory OAuth 2.0 Client Provider for The PHP League OAuth2-Client

2509.6M48](/packages/thenetworg-oauth2-azure)[robsontenorio/laravel-keycloak-guard

🔑 Simple Keycloak Guard for Laravel

5161.1M3](/packages/robsontenorio-laravel-keycloak-guard)[socialiteproviders/microsoft

Microsoft OAuth2 Provider for Laravel Socialite

326.1M13](/packages/socialiteproviders-microsoft)[rainlab/user-plugin

User plugin for October CMS

11954.3k13](/packages/rainlab-user-plugin)[kinde-oss/kinde-auth-php

Kinde PHP SDK for authentication

2369.5k3](/packages/kinde-oss-kinde-auth-php)[kakadu-dev/yii2-jwt-auth

Extension provide JWT auth for Yii2

105.8k](/packages/kakadu-dev-yii2-jwt-auth)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
