Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Oauth2 Server Httpfoundation Bridge Laravel Package

binhvd/oauth2-server-httpfoundation-bridge

Bridge package that integrates an OAuth2 server with Symfony HttpFoundation, providing request/response adapters so you can use HttpFoundation objects when working with OAuth2 flows in Laravel/PHP applications.

View on GitHub
Deep Wiki
Context7

oauth2-server-httpfoundation-bridge

A bridge to HttpFoundation for oauth2-server-php.

Build Status

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.

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

Installation

Composer is the best way to install this library. Add this line to composer.json:

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

And then run composer.phar install

Match tags with the oauth2-server-php library when possible. v1.1 is the latest tag.

Creating the request

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

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

The Request object is now compatible with both HttpFoundation and oauth2-server-php

// 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:

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:

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.

Examples

Contact

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

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle