2017 © Pedro Peláez
 

library oauth2-server-httpfoundation-bridge

A bridge to HttpFoundation for oauth2-server-php

image

bshaffer/oauth2-server-httpfoundation-bridge

A bridge to HttpFoundation for oauth2-server-php

  • Tuesday, December 27, 2016
  • by bshaffer
  • Repository
  • 4 Watchers
  • 41 Stars
  • 514,204 Installations
  • PHP
  • 16 Dependents
  • 0 Suggesters
  • 31 Forks
  • 7 Open issues
  • 11 Versions
  • 7 % Grown

The README.md

oauth2-server-httpfoundation-bridge

A bridge to HttpFoundation for oauth2-server-php., (*1)

oauth2-server-httpfoundation-bridge is a wrapper for oauth2-server-php which returns Symfony\Component\HttpFoundation\Response instead of OAuth2\Response, and uses Symfony\Component\HttpFoundation\Request instead of OAuth2\Request., (*2)

If you are integrating OAuth2 into a Silex, Symfony, or Laravel 4 app, (or any app using HttpFoundation), this will make your application much cleaner, (*3)

Installation

Composer is the best way to install this library. Add this line to composer.json:, (*4)

{
    "require": {
        "bshaffer/oauth2-server-httpfoundation-bridge": "v1.0",
        ...
    },
    ...
}

And then run composer.phar install, (*5)

Match tags with the oauth2-server-php library when possible. v1.1 is the latest tag., (*6)

Creating the request

Creating the request object is the same as before, except now you use the OAuth2\HttpFoundationBridge\Request class:, (*7)

$request = OAuth2\HttpFoundationBridge\Request::createFromGlobals();
$app->run($request);

The Request object is now compatible with both HttpFoundation and oauth2-server-php, (*8)

// getBaseUrl is unique to HttpFoundation
$baseUrl = $request->getBaseUrl();

// call oauth server
$server->grantAccessToken($request);

If the HttpFoundation request already exists, you can use the static createFromRequest function to build the OAuth2\HttpFoundationBridge\Request instance:, (*9)

use OAuth2\HttpFoundationBridge\Request as BridgeRequest;

// in your controller layer, the $request object is passed in
public function execute(Request $request)
{
    //... (instantiate server/response objects)
    $bridgeRequest = BridgeRequest::createFromRequest($request);
    $server->grantAccessToken($bridgeRequest, $response);
}

Creating the response

The OAuth2\HttpFoundationBridge\Response object extends Symfony\Component\HttpFoundation\JsonResponse, and implements OAuth2\ResponseInterface, allowing you to pass this in and return it from your controllers. In Symfony and Silex, this will be all that is needed to integrate the server:, (*10)

use OAuth2\HttpFoundationBridge\Response as BridgeResponse;

// in your controller layer, the $request object is passed in
public function execute(Request $request)
{
    //... (instantiate server/response objects)
    $response = new BridgeResponse();
    return $server->handleTokenRequest($request, $response);
}

Note: this object will return JSON. Implement your own class using OAuth2\ResponseInterface to support a different content-type., (*11)

Examples

Contact

Please contact Brent Shaffer (bshafs gmail com) for more information, (*12)

The Versions

27/12 2016

dev-master

9999999-dev http://github.com/bshaffer/oauth2-server-httpfoundation-bridge

A bridge to HttpFoundation for oauth2-server-php

  Sources   Download

MIT

The Requires

 

oauth auth oauth2 httpfoundation

27/12 2016

dev-develop

dev-develop http://github.com/bshaffer/oauth2-server-httpfoundation-bridge

A bridge to HttpFoundation for oauth2-server-php

  Sources   Download

MIT

The Requires

 

oauth auth oauth2 httpfoundation

27/12 2016

V1.3

1.3.0.0 http://github.com/bshaffer/oauth2-server-httpfoundation-bridge

A bridge to HttpFoundation for oauth2-server-php

  Sources   Download

MIT

The Requires

 

oauth auth oauth2 httpfoundation

27/08 2014

v1.1

1.1.0.0 http://github.com/bshaffer/oauth2-server-httpfoundation-bridge

A bridge to HttpFoundation for oauth2-server-php

  Sources   Download

MIT

The Requires

 

oauth auth oauth2 httpfoundation

27/08 2014

v1.2

1.2.0.0 http://github.com/bshaffer/oauth2-server-httpfoundation-bridge

A bridge to HttpFoundation for oauth2-server-php

  Sources   Download

MIT

The Requires

 

oauth auth oauth2 httpfoundation

06/09 2013

v1.0

1.0.0.0 http://github.com/bshaffer/oauth2-server-httpfoundation-bridge

A bridge to HttpFoundation for oauth2-server-php

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

oauth auth oauth2 httpfoundation

11/06 2013

dev-php5.2-develop

dev-php5.2-develop http://github.com/bshaffer/oauth2-server-httpfoundation-bridge

A bridge to HttpFoundation for oauth2-server-php

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

oauth auth oauth2 httpfoundation

11/06 2013

v0.9

0.9.0.0 http://github.com/bshaffer/oauth2-server-httpfoundation-bridge

A bridge to HttpFoundation for oauth2-server-php

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

oauth auth oauth2 httpfoundation

25/04 2013

v0.6

0.6.0.0 http://github.com/bshaffer/oauth2-server-httpfoundation-bridge

A bridge to HttpFoundation for oauth2-server-php

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

oauth auth oauth2 httpfoundation

25/04 2013

v0.7

0.7.0.0 http://github.com/bshaffer/oauth2-server-httpfoundation-bridge

A bridge to HttpFoundation for oauth2-server-php

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

oauth auth oauth2 httpfoundation

27/03 2013

v0.5

0.5.0.0 http://github.com/bshaffer/oauth2-server-httpfoundation-bridge

A bridge to HttpFoundation for oauth2-server-php

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

oauth auth oauth2 httpfoundation