Developed with love by KnpLabs Hire us for your project!
26

CasAuthBundle

by PRayno

Basic CAS (SSO) authenticator for Symfony 3 and 4

CasAuthBundle

Basic CAS (SSO) authenticator for Symfony 3 and 4

This bundle provides a -very- basic CAS (http://jasig.github.io/cas/4.1.x/index.html) authentication client for Symfony 3 and 4.

Installation

Install the library via Composer by
running the following command:

composer require prayno/casauth-bundle

Next, enable the bundle in your app/AppKernel.php file:

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new PRayno\CasAuthBundle\PRaynoCasAuthBundle(),
        // ...
    );
}

In config.yml (Symfony 3) or config/packages/p_rayno_cas_auth.yaml (create this file in Symfony 4), add these settings :
yaml
p_rayno_cas_auth:
server_login_url: https://mycasserver/cas/
server_validation_url: https://mycasserver/cas/serviceValidate
server_logout_url: https://mycasserver/cas/logout
xml_namespace: cas
options:[] see http://docs.guzzlephp.org/en/latest/request-options.html

Note : the xml_namespace and options parameters are optionals

Modify your security.yml with the following values (the provider in the following settings should not be used as it's just a very basic example ; in production, create your own UserProvider and add its service name in providers:cas:id) :
```yaml
security:
providers:
cas:
id: prayno.cas_user_provider

firewalls:
    dev:
        pattern: ^/(_(profiler|wdt)|css|images|js)/
        security: false
    main:
        anonymous: ~
        logout: ~
        guard:
            authenticators:
                - prayno.cas_authenticator

access_control:
    - { path: ^/, roles: ROLE_USER }

  And voila ! Your secured route should redirect you to your CAS login page which should authenticate you.


## CAS global logout option

If you want your users to logout from the remote CAS server when logging out from your app, you should apply the following settings :

security.yaml:

```yaml
# ...
    firewalls:
        # ...
        main:
          # ...
          logout:
            path: /logout
            success_handler: PRayno\CasAuthBundle\Event\LogoutSuccessHandler

services.yaml

# ...
services:
    # ...
    PRayno\CasAuthBundle\Event\LogoutSuccessHandler:
        arguments:
            $logoutUrl: "%cas_logout_url%"

Of course, you must set a "cas_logout_url" parameter in your app (eg. https://my_remote_cas_server/logout)

Don't forget to define a /logout route in your app

MIT License

Copyright (c) 2016 Pierre Raynaud

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
p_rayno_cas_auth:
server_login_url: ~
server_validation_url: ~
server_logout_url: ~
xml_namespace: cas
options: []
username_attribute: user
query_ticket_parameter: ticket
query_service_parameter: service
  • Add a remote CAS logout service
    By Pierre Raynau, 1 year ago
  • Merge pull request #15 from gcaux/master
    By web-flow, 1 year ago
  • Adding Event for AuthenticationFailure
    By , 1 year ago
  • Fixed licence issue
    By piraynau, 1 year ago
  • Update README.md
    By web-flow, 1 year ago
  • Merge pull request #11 from cilefen/sf4-compatibility
    By web-flow, 1 year ago
  • Make compatible with Symfony 4
    By , 1 year ago
  • Added license and a few comments
    By PRayno, 2 years ago
  • Merge pull request #4 from middlebury/remove_ticket_on_success
    By web-flow, 2 years ago
  • `urlencode()` the service parameter in case it contains query parameters itself.
    By , 2 years ago
  • Strip the CAS ticket from the service parameter when validating tickets.
    By adamfranco, 2 years ago
  • After successful authentication, strip the CAS ticket parameter from the URI.
    By adamfranco, 2 years ago
  • Merge pull request #2 from e-ReColNat/master
    By PRayno, 3 years ago
  • Fix
    By Thomas Pateffoz, 3 years ago
  • Fix configuration
    By Thomas Pateffoz, 3 years ago
  • Bug fix
    By Thomas Pateffoz, 3 years ago
  • Bug fix
    By Thomas Pateffoz, 3 years ago
  • Update documentation
    By Thomas Pateffoz, 3 years ago
  • Use Guzzle
    By Thomas Pateffoz, 3 years ago
  • Remove php requirement
    By PRayno, 3 years ago
  • Change minimum stability
    By PRayno, 3 years ago
  • Works on SF 2.8
    By PRayno, 3 years ago
  • Configuration added
    By PRayno, 3 years ago
  • Update README.md
    By PRayno, 3 years ago
  • Init
    By PRayno, 3 years ago
  • Initial commit
    By PRayno, 3 years ago