Download the PHP package univlorraine/symfony-cas-bundle without Composer
On this page you can find all versions of the php package univlorraine/symfony-cas-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download univlorraine/symfony-cas-bundle
More information about univlorraine/symfony-cas-bundle
Files in univlorraine/symfony-cas-bundle
Package symfony-cas-bundle
Short Description Symfony 5.4+ bundle for CAS Authentication wrapping phpCAS lib from Apereo
License CECILL-2.1
Informations about the package symfony-cas-bundle
Symfony Cas Bundle
This bundle provides a CAS authentication client for Symfony 5.4+, wrapping the phpCAS library from Apereo (https://www.apereo.org/projects/cas).
Requirements
- PHP 7.4 or greater
- Symfony 5.4 or greater
Installation
-
Require the bundle using Composer:
- Declare the bundle in Symfony Kernel if it's not already in (should be added automatically). In config/bundles.php:
Configuration
Create the config file config/packages/univ_lorraine_symfony_cas.yaml, and add these settings:
- cas_url: CAS server url (HTTP(S) scheme is not required).
- cas_context: possible additional path to access CAS Server if not root (eg: my-cas.cas.com/cas).
- cas_port: server port. If not set, the bundle will use default 443 port.
- cas_service_base_url: Url of the running app
- cas_ca_cert: path to the SSL CA Certificate.
- cas_login_redirect: the path the user will be redirected to after he logged in successfully. (It is only triggered when the user goes through the /login url, otherwise he will be automatically redirected to the url he requested, after he logged in).
- cas_logout_redirect: the path or url the user will be redirected to after he logged out. If not set, the user will be redirected to the CAS Server success logout page.
- cas_version: the version of the CAS Server used.
- public_access_regex: a regex with public_access URls declared in security.yaml for which you want to retrieve the user (if authenticated)
Routes configuration
The bundle provides 2 routes :
- /login
- /logout
For adding these routes to your app, create the file config/routes/univ_lorraine_symfony_cas.yaml, and add these settings:
Feel free to use a different name as prefix, just remember it for the next security part.
Security Configuration
Update the security config file config/packages/security.yaml.
-
Enable custom authenticator:
-
Create / update your secure area to use CAS authentication:
- Create public access for the login route (if behind secure area):
SSO Logout
This bundle is configured to logout from Symfony AND from the CAS.
Additional user attributes
The CAS Server can return additional attributes in addition to the main attributes (uid). When the user is authenticated, it is possible to get these attributes through the security token of Symfony:
Customize error pages
The bundle triggers an event (named univ_lorraine_symfony_cas.authentication_failure) during authentication failure, with 2 different error codes:
- 403 FORBIDDEN : when the user provider cannot find the authenticated user
- 401 UNAUTHORIZED: when an error occurs during the CAS authentication
You can use this event to customize the error pages.
-
Create an Event Listener (eg: src/Event/AuthenticationFailureListener.php):
- Register your listener in the services. In config/services.yaml:
License
See the LICENSE file for copyrights and limitations (CeCILL 2.1).
All versions of symfony-cas-bundle with dependencies
apereo/phpcas Version ~1.6.1
symfony/framework-bundle Version ^5.4|^6.0
symfony/security-bundle Version ^5.4|^6.0