PHPackages                             ekalokman/yii2-cas-uni - 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. ekalokman/yii2-cas-uni

ActiveYii2-extension

ekalokman/yii2-cas-uni
======================

CAS authentication for Yii2 from silecs/yii2-auth-cas

081PHP

Since Aug 12Pushed 1y ago1 watchersCompare

[ Source](https://github.com/ekalokman/yii2-cas-uni)[ Packagist](https://packagist.org/packages/ekalokman/yii2-cas-uni)[ RSS](/packages/ekalokman-yii2-cas-uni/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

yii2-cas-uni
============

[](#yii2-cas-uni)

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 ekalokman/yii2-auth-uni`
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', //insert your own host
                    'port' => '443', //insert your own port
                    'path' => '/cas',
                    'returnUrl' => '', //insert your own return url
                    // 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, 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();
    }

    ```
4. Add actions that use casAuthenticate to check user is student or staff and register new user, in `common/models/LoginCas.php` :

    ```
