PHPackages                             sindria/oauth2-keycloak - 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. sindria/oauth2-keycloak

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

sindria/oauth2-keycloak
=======================

A wrapper for the Keycloak OAuth 2.0 Client Provider

1.0.0(3y ago)05MITPHPPHP ^7.3|^8.0

Since Apr 29Pushed 3y agoCompare

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

READMEChangelogDependencies (5)Versions (2)Used By (0)

oauth2-keycloak
===============

[](#oauth2-keycloak)

A wrapper for the Keycloak OAuth 2.0 Client Provider, support Authentication and Authorization.

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

[](#installation)

To install, use composer:

```
composer require sindria/oauth2-keycloak
```

Init
----

[](#init)

```
$passport = Passport::init([
    'authServerUrl' => 'http://127.0.0.1:8080/auth',
    'realm'         => 'xxxx',
    'clientId'      => 'backend',
    'clientSecret'  => 'xxxxx',
    'redirectUri'   => 'http://127.0.0.1:8003/auto',
    'periodNoCheck' => 3600,
    'periodCheck'   => 180,
]);
```

Authentication
--------------

[](#authentication)

### Login

[](#login)

```
$user = $passport->checkLogin();
$user->getAttr('username');
$user->toArray();
```

### logout

[](#logout)

```
$passport->logout();
```

### Other Methds

[](#other-methds)

```
$passport->getAccessToken(); // can save in client
$passport->getToken(); // secret
$passport->getAuthorizationUrl();
$passport->getLogoutUrl();
```

Authorization
-------------

[](#authorization)

```
$user = $passport->checkAuth();

// permission
$user->can($resource, $scope);
$user->cannot($resource, $scope);

// list
$user->getClients();
$user->getPermissions();

// role
$user->getRoles();
$user->hasRole($role);
$user->inRoles($roleList);
```

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 81.8% 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

Unknown

Total

1

Last Release

1107d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/88d66fa70f20a8eb03723d4fa614f8f2d70e4dd2d6d97f6cf22fdb3f542d19c7?d=identicon)[lucapitzoi](/maintainers/lucapitzoi)

---

Top Contributors

[![zhenyangze](https://avatars.githubusercontent.com/u/15710584?v=4)](https://github.com/zhenyangze "zhenyangze (27 commits)")[![lucapitzoi](https://avatars.githubusercontent.com/u/35993148?v=4)](https://github.com/lucapitzoi "lucapitzoi (6 commits)")

---

Tags

clientoauthoauth2authorizationauthorisationkeycloak

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/sindria-oauth2-keycloak/health.svg)

```
[![Health](https://phpackages.com/badges/sindria-oauth2-keycloak/health.svg)](https://phpackages.com/packages/sindria-oauth2-keycloak)
```

###  Alternatives

[stevenmaguire/oauth2-keycloak

Keycloak OAuth 2.0 Client Provider for The PHP League OAuth2-Client

2275.9M27](/packages/stevenmaguire-oauth2-keycloak)[patrickbussmann/oauth2-apple

Sign in with Apple OAuth 2.0 Client Provider for The PHP League OAuth2-Client

1132.5M6](/packages/patrickbussmann-oauth2-apple)[thenetworg/oauth2-azure

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

2509.6M48](/packages/thenetworg-oauth2-azure)

PHPackages © 2026

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