PHPackages                             sngular/sngulauth - 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. sngular/sngulauth

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

sngular/sngulauth
=================

Auth package against Keycloak for Saml and Openid-Connect

1.5(5y ago)02.8kMITPHPCI failing

Since Aug 2Pushed 5y ago1 watchersCompare

[ Source](https://github.com/manuel-garcia-sn/sngulauth)[ Packagist](https://packagist.org/packages/sngular/sngulauth)[ Docs](https://www.sngular.com/)[ RSS](/packages/sngular-sngulauth/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (10)Dependencies (5)Versions (15)Used By (0)

This is the ultimate package for manage Keycloak authentication with Openid Connect
===================================================================================

[](#this-is-the-ultimate-package-for-manage-keycloak-authentication-with-openid-connect)

### Before start, you need some parameters

[](#before-start-you-need-some-parameters)

- **authServerUrl**: keycloak auth url
- **realm**: realm name that has been set up for the project
- **clientId**: client id name that has been set up for the project
- **clientSecret**: client secret name that has been set up for the project
- **redirectUri**: the redirect url to be redirected after successful credentials prompt (this url must be valid on keycloak client configuration)
- **encryptionAlgorithm**: algorithm to decode the JWT information, default is RS256
- **encryptionKeyString**: the public key content in one line (without BEGIN PUBLIC KEY and END PUBLIC KEY) in order to decrypt the JWT and get the user info.

### The auth process

[](#the-auth-process)

The src/Provider/Keycloak/Protocol/Connect class needs an array to be instantiated with those parameters:

```
$auth = new Connect($config);

```

Then you can build the auth url to redirect user or display a link:

```
$authUrl = $auth->getAuthorizationUrl();

```

After user insert his credentials on Keycloak login page, it will be redirected to **redirectUri** parameter, with a code. Now you can fetch a token (League\\OAuth2\\Client\\Token\\AccessToken) against keycloak with those code:

```
$token = $auth->authByCode($_GET['code']);
```

Now you can get the resource owner (the user data) against keycloak

```
$user = $auth->getResourceOwner($token);

```

And decrypt the token to get the token payload:

```
$userData = $auth->decryptResponse($token->getToken());

```

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 80% 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 ~32 days

Recently: every ~54 days

Total

14

Last Release

2098d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3dfe98c03abfec531bfdd7bd60d3e55b05e46d4bd45f79824e8696e6cd52638f?d=identicon)[manuel-garcia-sn](/maintainers/manuel-garcia-sn)

---

Top Contributors

[![manuel-garcia-sn](https://avatars.githubusercontent.com/u/52311652?v=4)](https://github.com/manuel-garcia-sn "manuel-garcia-sn (12 commits)")[![mjgr0013](https://avatars.githubusercontent.com/u/8981247?v=4)](https://github.com/mjgr0013 "mjgr0013 (2 commits)")[![subsider](https://avatars.githubusercontent.com/u/6003993?v=4)](https://github.com/subsider "subsider (1 commits)")

---

Tags

authsamlconnectkeycloakoneloginsngular

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/sngular-sngulauth/health.svg)

```
[![Health](https://phpackages.com/badges/sngular-sngulauth/health.svg)](https://phpackages.com/packages/sngular-sngulauth)
```

###  Alternatives

[google/auth

Google Auth Library for PHP

1.4k286.7M205](/packages/google-auth)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

751284.3k37](/packages/civicrm-civicrm-core)[tempest/framework

The PHP framework that gets out of your way.

2.2k31.1k12](/packages/tempest-framework)[stevenmaguire/oauth2-keycloak

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

2276.2M36](/packages/stevenmaguire-oauth2-keycloak)[ellaisys/aws-cognito

AWS Cognito package that allows Auth and other related features using the AWS SDK for PHP

121242.9k1](/packages/ellaisys-aws-cognito)[xeroapi/xero-php-oauth2

Xero official PHP SDK for oAuth2 generated with OpenAPI spec 3

1054.6M18](/packages/xeroapi-xero-php-oauth2)

PHPackages © 2026

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