PHPackages                             silecs/yii2-auth-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. silecs/yii2-auth-cas

ActiveYii2-extension[Authentication &amp; Authorization](/categories/authentication)

silecs/yii2-auth-cas
====================

CAS authentication for Yii2

1.0.7(2y ago)75724MITPHPPHP &gt;=7.4.0

Since Oct 10Pushed 2y ago4 watchersCompare

[ Source](https://github.com/silecs/yii2-auth-cas)[ Packagist](https://packagist.org/packages/silecs/yii2-auth-cas)[ RSS](/packages/silecs-yii2-auth-cas/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (5)Dependencies (1)Versions (8)Used By (0)

yii2-auth-cas
=============

[](#yii2-auth-cas)

Yii2 library for authentication by CAS, using the library [phpCAS](https://github.com/apereo/phpCAS).

Usage
-----

[](#usage)

1. Add this to the project with `composer require silecs/yii2-auth-cas`
2. Configure the Yii2 application, e.g. in `backend/config/main.php` :

    ```
    return [
        ...
        'modules' => [
            'cas' => [
                'class' => 'silecs\yii2auth\cas\CasModule',
                'config' => [
                    'host' => 'ssoserver.example.com',
                    'port' => '443',
                    'path' => '/idp/profile/cas',
                    // optional parameters
                    'certfile' => '', // empty, or path to a SSL cert, or false to ignore certs
                    'debug' => true, // will add many logs into X/runtime/logs/cas.log
                ],
            ],

    ```
3. Add actions that use this CAS module, e.g. in `SiteController` :

    ```
    public function actionLogin()
    {
        if (!Yii::$app->user->isGuest) {
            return $this->goHome();
        }
        return $this->redirect(['/cas/auth/login']);
    }

    public function actionLogout()
    {
        if (Yii::$app->user->isGuest) {
            return $this->redirect(['/cas/auth/logout']);
        }
        return $this->goHome();
    }

    ```

Notes
-----

[](#notes)

The `user` component that implements `yii\web\IdentityInterface`will be used to fetch the local profile after querying the CAS server. It means that if `User` is the App component and CAS returns a username of "bibendum", the authentication will be successful if and only if the result of `User::findIdentity("bibendum")` is not null.

The action path '/cas/auth/login' starts with the alias of the module, as defined in the application configuration, e.g. `'cas'` in `'modules' => [ 'cas' => [ ... ] ]`.

### Testing with a CAS container

[](#testing-with-a-cas-container)

Here are some instructions on deploying a Docker CAS server to test this library. This procedure will use the CAS interface of a Shibboleth instance. This was tested on Debian Stretch and Buster (testing).

1. Install `docker` from the extra repository at docker.io (I had errors with the older docker from the official Debian repository).
2. Install `docker-compose` either from Debian or docker.io.
3. Git clone If using an old docker-compose, then chekout 3c29f10 because later commits require a too recent feature.
4. Modify `docker-compose.yml` so that the container won't try to use the port 80, so replace `"80:80"` with `"8080:80"`.
5. If your local Yii2 application is not using HTTPS, modify `idp/shibboleth-idp/conf/cas-protocol.xml`to replace `c:regex="https://idptestbed/.*"` by `c:regex="https?://idptestbed/.*"`.
6. Add `127.0.0.1 idptestbed` to `/etc/hosts`, as root.
7. Configure your Yii2 application to use:

    ```
     'host' => 'idptestbed',
     'port' => '443',
     'path' => '/idp/profile/cas',
     'certfile' => false,
     'debug' => true,

    ```
8. Start the containers:

    ```
     docker-compose build
     docker-compose run

    ```
9. Go to the login page of your Yii2 app.
10. Ctrl-C in the containers termainal to end them.

You can modify `ldap/users.ldif` if you want to add users to the CAS. Don't forget to rebuild the Docker images after this.

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 66.7% 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 ~382 days

Recently: every ~533 days

Total

7

Last Release

841d ago

PHP version history (2 changes)1.0.1PHP &gt;=5.4.0

1.0.7PHP &gt;=7.4.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/304291ff5d445f487c718fbb74aa4a0d823d1951b4fbfce1d3371285af93179b?d=identicon)[mytskine](/maintainers/mytskine)

---

Top Contributors

[![apaoww](https://avatars.githubusercontent.com/u/4974699?v=4)](https://github.com/apaoww "apaoww (2 commits)")[![mytskine](https://avatars.githubusercontent.com/u/516560?v=4)](https://github.com/mytskine "mytskine (1 commits)")

---

Tags

Authenticationcasyii2yii

### Embed Badge

![Health badge](/badges/silecs-yii2-auth-cas/health.svg)

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

###  Alternatives

[amnah/yii2-user

Yii 2 user authentication module

252225.7k3](/packages/amnah-yii2-user)[2amigos/yii2-usuario

Highly customizable and extensible user management, authentication, and authorization Yii2 extension

298275.5k14](/packages/2amigos-yii2-usuario)[crisu83/yii-auth

Web UI for the authorization manager of Yii PHP framework.

13439.8k](/packages/crisu83-yii-auth)

PHPackages © 2026

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