PHPackages                             ajtak/oauth2-apereo-cas - 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. ajtak/oauth2-apereo-cas

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

ajtak/oauth2-apereo-cas
=======================

Apereo CAS OAuth 2.0 Client Provider for The PHP League OAuth2-Client

0.2.0(2y ago)011MITPHPPHP ^7.3 || ^8.0

Since Jul 28Pushed 2y ago1 watchersCompare

[ Source](https://github.com/Ajtak/oauth2-apereo-cas)[ Packagist](https://packagist.org/packages/ajtak/oauth2-apereo-cas)[ RSS](/packages/ajtak-oauth2-apereo-cas/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (4)Versions (2)Used By (0)

Apereo CAS Provider for OAuth 2.0 Client
========================================

[](#apereo-cas-provider-for-oauth-20-client)

[![Latest Version](https://camo.githubusercontent.com/74047a8ff8a3107d7a99783bd956f464c89573cb95764eaa3a546629a03ac180/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f616a74616b2f6f61757468322d61706572656f2d6361732e7376673f7374796c653d666c61742d737175617265)](https://github.com/ajtak/oauth2-apereo-cas/releases)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Coverage Status](https://camo.githubusercontent.com/51849aab6e5c2b022ad67bc1639ac369d75bf73f23555b651ce3edfc954c1530/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f616a74616b2f6f61757468322d61706572656f2d6361732e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/ajtak/oauth2-apereo-cas/code-structure)[![Quality Score](https://camo.githubusercontent.com/6869d84fcb9791bdf910d51a4b7703c7ccd3b0109833318ea224a59ebf8aa986/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f616a74616b2f6f61757468322d61706572656f2d6361732e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/ajtak/oauth2-apereo-cas)[![Total Downloads](https://camo.githubusercontent.com/83e257de1e7ceaaab5acdc1a464b018529dcc1b6091e83b6fe63982bae6fc40b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f616a74616b2f6f61757468322d61706572656f2d6361732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ajtak/oauth2-apereo-cas)

This package provides Apereo CAS OAuth 2.0 / OIDC support for the PHP League's [OAuth 2.0 Client](https://github.com/thephpleague/oauth2-client).

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

[](#installation)

To install, use composer:

```
composer require ajtak/oauth2-apereo-cas

```

Usage
-----

[](#usage)

Usage is the same as The League's OAuth client, using `\Ajtak\OAuth2\Client\Provider\ApereoCas` as the provider.

### Authorization Code Flow

[](#authorization-code-flow)

```
$provider = new Ajtak\OAuth2\Client\Provider\ApereoCas([
    'authServerUrl'     => 'cas-server-url',
    'clientId'          => '{cas-client-id}',
    'clientSecret'      => '{cas-client-secret}',
    'redirectUri'       => 'https://example.com/callback-url',
]);

if (!isset($_GET['code'])) {

    // If we don't have an authorization code then get one
    $authUrl = $provider->getAuthorizationUrl();
    $_SESSION['oauth2state'] = $provider->getState();
    header('Location: '.$authUrl);
    exit;

// Check given state against previously stored one to mitigate CSRF attack
} elseif (empty($_GET['state']) || ($_GET['state'] !== $_SESSION['oauth2state'])) {

    unset($_SESSION['oauth2state']);
    exit('Invalid state');

} else {

    // Try to get an access token (using the authorization code grant)
    $token = $provider->getAccessToken('authorization_code', [
        'code' => $_GET['code']
    ]);

    // Optional: Now you have a token you can look up a users profile data
    try {

        // We got an access token, let's now get the user's details
        $user = $provider->getResourceOwner($token);

        // Use these details to create a new profile
        printf('Hello %s (%s)!', $user->getName(), $user->getEmail());

    } catch (Exception $e) {

        // Failed to get user details
        exit('Oh dear...');
    }

    // Use this to interact with an API on the users behalf
    echo $token->getToken();
}
```

Testing
-------

[](#testing)

```
$ ./vendor/bin/phpunit
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](https://github.com/ajtak/oauth2-apereo-cas/blob/master/CONTRIBUTING.md) for details.

Credits
-------

[](#credits)

- [Jakub Fridrich](https://github.com/ajtak)
- [Steven Maguire](https://github.com/stevenmaguire)
- [All Contributors](https://github.com/ajtak/oauth2-apereo-cas/contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](https://github.com/ajtak/oauth2-apereo-cas/blob/master/LICENSE) for more information.

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

 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

Unknown

Total

1

Last Release

1020d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3acdcc0a783886e6f7c35de50532a192060fb8bddc04498a103c793fd02e500a?d=identicon)[Ajtak](/maintainers/Ajtak)

---

Top Contributors

[![jakub-klik-it](https://avatars.githubusercontent.com/u/158166725?v=4)](https://github.com/jakub-klik-it "jakub-klik-it (12 commits)")

---

Tags

clientoauthoauth2authorizationauthorisationapereo-cas

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/ajtak-oauth2-apereo-cas/health.svg)

```
[![Health](https://phpackages.com/badges/ajtak-oauth2-apereo-cas/health.svg)](https://phpackages.com/packages/ajtak-oauth2-apereo-cas)
```

###  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)[mollie/oauth2-mollie-php

Mollie Provider for OAuth 2.0 Client

251.7M1](/packages/mollie-oauth2-mollie-php)[omines/oauth2-gitlab

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

36721.5k13](/packages/omines-oauth2-gitlab)

PHPackages © 2026

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