Download the PHP package silecs/yii2-auth-cas without Composer
On this page you can find all versions of the php package silecs/yii2-auth-cas. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download silecs/yii2-auth-cas
More information about silecs/yii2-auth-cas
Files in silecs/yii2-auth-cas
Informations about the package yii2-auth-cas
yii2-auth-cas
Yii2 library for authentication by CAS, using the library phpCAS.
Usage
-
Add this to the project with
composer require silecs/yii2-auth-cas
-
Configure the Yii2 application, e.g. in
backend/config/main.php
: - Add actions that use this CAS module, e.g. in
SiteController
:
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
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).
-
Install
docker
from the extra repository at docker.io (I had errors with the older docker from the official Debian repository). -
Install
docker-compose
either from Debian or docker.io. -
Git clone https://hub.docker.com/r/unicon/shibboleth-idp/ If using an old docker-compose, then chekout 3c29f10 because later commits require a too recent feature.
-
Modify
docker-compose.yml
so that the container won't try to use the port 80, so replace"80:80"
with"8080:80"
. -
If your local Yii2 application is not using HTTPS, modify
idp/shibboleth-idp/conf/cas-protocol.xml
to replacec:regex="https://idptestbed/.*"
byc:regex="https?://idptestbed/.*"
. -
Add
127.0.0.1 idptestbed
to/etc/hosts
, as root. -
Configure your Yii2 application to use:
'host' => 'idptestbed', 'port' => '443', 'path' => '/idp/profile/cas', 'certfile' => false, 'debug' => true,
-
Start the containers:
docker-compose build docker-compose run
-
Go to the login page of your Yii2 app.
- 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.