2017 © Pedro Peláez
 

library silex-opauth

Opauth silex framework service provider.

image

icehero/silex-opauth

Opauth silex framework service provider.

  • Sunday, March 4, 2018
  • by icehero
  • Repository
  • 4 Watchers
  • 33 Stars
  • 7,586 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 16 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Usage

Simple, event driven silex extension

    // Configure opauth
    $app['opauth'] = array(
      'login' => '/auth',
      'callback' => '/auth/callback',
      'config' => array(
        'security_salt' => '...your salt...',
        'Strategy' => array(
            'Facebook' => array(
               'app_id' => '...',
               'app_secret' => '...'
             ),
        )
      )
    );

    // Enable extension
    $app->register(new OpauthExtension());

    // Listen for events
    $app->on(OpauthExtension::EVENT_ERROR, function($e) {
        $this->log->error('Auth error: ' . $e['message'], ['response' => $e->getSubject()]);
        $e->setArgument('result', $this->redirect('/'));
    });

    $app->on(OpauthExtension::EVENT_SUCCESS, function($e) {
        $response = $e->getSubject();

        /*
           find/create a user, oauth response is in $response and it's already validated!
           store the user in the session
        */

        $e->setArgument('result', $this->redirect('/'));
    });

Advanced, symfony security listener+provider

Note, that you can use it in symfony2 projects too!, (*1)

To login using opauth use /login/PROVIDER, or use opauth_default_login route with provider parameter., (*2)


$app->register(new OpauthSilexProvider()); $app->register(new SecurityServiceProvider(), array( 'security.firewalls' => array( 'default' => array( 'pattern' => '^/.*', 'opauth' => array( // 'check_path' => '/login/opauth', //default 'opauth' => [ // 'path' => '/login', //default 'security_salt' => '...your salt...', 'Strategy' => [ // your opauth strategies go here ] ] ), 'anonymous' => true, ), ) );

By default, users will be looked up by username "provider:uid"., (*3)

You should extend your user provider to handle OPauth results correctly by implementing OpauthUserProviderInterface., (*4)

The Versions

04/03 2018

dev-master

9999999-dev https://github.com/icehero/silex-opauth

Opauth silex framework service provider.

  Sources   Download

The Requires

 

The Development Requires

oauth opauth silex