2017 © Pedro Peláez
 

symfony-bundle raven-bundle

Adds Raven authentication to your Symfony2 application

image

misd/raven-bundle

Adds Raven authentication to your Symfony2 application

  • Friday, January 2, 2015
  • by thewilkybarkid
  • Repository
  • 2 Watchers
  • 1 Stars
  • 2,225 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 3 Open issues
  • 5 Versions
  • 2 % Grown

The README.md

MisdRavenBundle

Build Status, (*1)

This bundle contains a Symfony2 authentication provider so that users can log in to a Symfony2 application through Raven, the University of Cambridge's central authentication service., (*2)

It also contains a user provider, which can allow any user authenticating through Raven access to your application., (*3)

Authors

The bundle uses code based on the UcamWebauth PHP class., (*4)

Requirements

Installation

  1. Add the bundle to your dependencies:, (*5)

    // composer.json
    
    {
       // ...
       "require": {
           // ...
           "misd/raven-bundle": "~1.0"
       }
    }
  2. Use Composer to download and install the bundle:, (*6)

    $ php composer.phar update misd/raven-bundle
  3. Register the bundle in your application:, (*7)

    // app/AppKernel.php
    
    class AppKernel extends Kernel
    {
        // ...
        public function registerBundles()
        {
            $bundles = array(
                // ...
                new Misd\RavenBundle\MisdRavenBundle(),
                // ...
            );
        }
        // ...
    }

Configuration

Firewall

To enable Raven authentication, add raven: true to a firewall configuration:, (*8)

// app/config/security.yml

security:
    firewalls:
        raven_secured:
            pattern: ^/secure/.*
            raven: true

User provision

Normal Symfony2 user providers can be used, as long as the username is the user's CRSid., (*9)

If you would like any user who has successfully authenticated with Raven to access your application, you can use the bundle's Raven user provider:, (*10)

// app/config/security.yml

security:
    providers:
        raven:
            id: raven.user_provider

The user provider returns an instance of Misd\RavenBundle\Security\User\RavenUser with the role ROLE_USER., (*11)

This can be chained with other providers to grant certain users extra roles. For example:, (*12)

// app/config/security.yml

security:
    providers:
        chain_provider:
            chain:
                providers: [in_memory, raven]
        in_memory:
            memory:
                users:
                    abc123: { roles: [ 'ROLE_ADMIN' ] }
        raven:
            id: raven.user_provider

Resource description

You can add the name of your application to the Raven log in page:, (*13)

// app/config/config.yml

misd_raven:
    description: "My application"

The text on the page will now include something like "This resource calls itself 'My application' and is ..."., (*14)

Test Raven service

During development, especially when not on the University network, it is sometimes necessary to use the test Raven Service. You can use this instead of the live service:, (*15)

// app/config/config_dev.yml

misd_raven:
    use_test_service: true

The test Raven service must not be used in production: it might compromise your application. Keep it to config_dev.yml!, (*16)

Exceptions

The bundle can throw various exceptions. To catch them, set up event listeners and implement your logic (display a message, redirect to another page etc)., (*17)

Misd\RavenBundle\Exception\AuthenticationCancelledException

This is thrown if the user clicks 'cancel' on the Raven log in screen., (*18)

Symfony\Component\Security\Core\Exception\UsernameNotFoundException

This is thrown if the user is not provisioned. If you're using the Raven user provider, this will never been seen., (*19)

Misd\RavenBundle\Exception\RavenException

This is thrown if something has gone wrong with either the bundle or Raven itself. As this is an exceptional state, you probably won't need to catch it (and let the 500 Internal Server Error be returned). It has the following sub-types:, (*20)

  • Misd\RavenBundle\Exception\LoginTimedOutException: If the Raven response is older than 30 seconds.

Misd\RavenBundle\Exception\OpenSslException

This is thrown if there is an OpenSSL problem., (*21)

Events

To listen for events that the bundle issues, create a normal event subscriber service:, (*22)

<service id="%my_listener.id%" class="%my_listener.class%">
    <tag name="kernel.event_listener" event="%raven_event%" method="%my_listener.method%"/>
</service>

The bundle issues the following events:, (*23)

raven.redirect

The Misd\RavenBundle\Event\RedirectEvent object contains the parameters given to Raven when the user is redirected to the login page. You could, for example, add the msg parameter., (*24)

raven.login

The Symfony\Component\Security\Http\Event\InteractiveLoginEvent object contains the request and the authentication token following a successful Raven login., (*25)

The Versions

02/01 2015

dev-master

9999999-dev https://github.com/misd-service-development/raven-bundle

Adds Raven authentication to your Symfony2 application

  Sources   Download

MIT

The Requires

 

The Development Requires

by Chris Wilkinson

authentication bundle university of cambridge

01/05 2013

1.0.x-dev

1.0.9999999.9999999-dev https://github.com/misd-service-development/raven-bundle

Adds Raven authentication to your Symfony2 application

  Sources   Download

MIT

The Requires

 

The Development Requires

by Chris Wilkinson

authentication bundle university of cambridge

08/03 2013

v1.1.0

1.1.0.0 https://github.com/misd-service-development/raven-bundle

Adds Raven authentication to your Symfony2 application

  Sources   Download

MIT

The Requires

 

The Development Requires

by Chris Wilkinson

authentication bundle university of cambridge

08/03 2013

v1.0.1

1.0.1.0 https://github.com/misd-service-development/raven-bundle

Adds Raven authentication to your Symfony2 application

  Sources   Download

MIT

The Requires

 

The Development Requires

by Chris Wilkinson

authentication bundle university of cambridge

29/01 2013

v1.0.0

1.0.0.0 https://github.com/misd-service-development/raven-bundle

Adds Raven authentication to your Symfony2 application

  Sources   Download

MIT

The Requires

 

The Development Requires

by Chris Wilkinson

authentication bundle university of cambridge