Skip to content

Latest commit

 

History

History
72 lines (55 loc) · 2.3 KB

README.md

File metadata and controls

72 lines (55 loc) · 2.3 KB

SleepnessUberOAuthRestBundle

Build Status Scrutinizer Code Quality Code Climate

Adds support for authenticating users via OAuth2 in Symfony2 REST

Motivation

You curious why you need this bundle, if there is shiny HWIOAuthBundle. HWIOAuthBundle requires sessions and forms

<service id="hwi_oauth.abstract_resource_owner.oauth2" class="%hwi_oauth.resource_owner.oauth2.class%"
         parent="hwi_oauth.abstract_resource_owner.generic" abstract="true">
    <argument type="service" id="hwi_oauth.storage.session" />
</service>
$formHandler = $this->container->get('hwi_oauth.registration.form.handler');
...
$this->authenticateUser($request, $form->getData(), $error->getResourceOwnerName(), $error->getRawToken());

meanwhile true RESTful app must be stateless

# app/config/security.yml
security:
    # ...

    firewalls:
        main:
            http_basic: ~
            stateless:  true

UberOAuthRestBundle aims Rest applications only. If you produce pure stateless app and want add few social stuff -- UberOAuthRestBundle this is exactly what you need. Bundle provides dead-simply Interface, and contains built-in handlers for popular SocialNetworks (OAuth servers)

Enable the bundle

Enable the bundle in the kernel:

// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new Sleepness\UberOAuthRestBundle\SleepnessUberOAuthRestBundle(),
    );
}

Configuring providers

To make this bundle work you need to add the following to your app/config/config.yml:

# app/config/config.yml
oauth_rest:
Built-in providers: