Static utilitiy classes to bridge PSR-7 http messages to OAuth2 Server requests and responses.

Overview

Chadicus\Slim\OAuth2\Http

Build Status Code Quality Code Coverage

Latest Stable Version Latest Unstable Version License

Total Downloads Daily Downloads Monthly Downloads

Documentation

Static utilitiy classes to bridge PSR-7 http messages to OAuth2 Server requests and responses. While this libray is entended for use with Slim 3, it should work with any PSR-7 compatible framework.

Requirements

Chadicus\Slim\OAuth2\Http requires PHP 5.6 (or later).

Composer

To add the library as a local, per-project dependency use Composer! Simply add a dependency on chadicus/slim-oauth2-http to your project's composer.json file such as:

composer require chadicus/slim-oauth2-http

Contact

Developers may be contacted at:

Project Build

With a checkout of the code get Composer in your PATH and run:

composer install
./vendor/bin/phpunit
./vendor/bin/phpcs

Community

Gitter

Available Operations

Convert a PSR-7 request to an OAuth2 request

use Chadicus\Slim\OAuth2\Http\RequestBridge;

$oauth2Request = RequestBridge::toOAuth2($psrRequest);

Convert an OAuth2 response to a PSR-7 response.

use Chadicus\Slim\OAuth2\Http\ResponseBridge;

$psr7Response = ResponseBridge::fromOAuth2($oauth2Request);

Example Integeration

Simple route for creating a new oauth2 access token

use Chadicus\Slim\OAuth2\Http\RequestBridge;
use Chadicus\Slim\OAuth2\Http\ResponseBridge;
use OAuth2;
use OAuth2\GrantType;
use OAuth2\Storage;
use Slim;

$storage = new Storage\Memory(
    [
        'client_credentials' => [
            'testClientId' => [
                'client_id' => 'testClientId',
                'client_secret' => 'testClientSecret',
            ],
        ],
    ]
);

$server = new OAuth2\Server(
    $storage,
    [
        'access_lifetime' => 3600,
    ],
    [
        new GrantType\ClientCredentials($storage),
    ]
);

$app = new Slim\App();

$app->post('/token', function ($psrRequest, $psrResponse, array $args) use ($app, $server) {
    //create an \OAuth2\Request from the current \Slim\Http\Request Object
    $oauth2Request = RequestBridge::toOAuth2($psrRequest);

    //Allow the oauth2 server instance to handle the oauth2 request
    $oauth2Response = $server->handleTokenRequest($oauth2Request),

    //Map the oauth2 response into the slim response
    return ResponseBridge::fromOAuth2($oauth2Response);
});
Comments
  • Rewind request body

    Rewind request body

    Request body is empty in subsequent middlewares, because it was not rewound.

    What does this PR do?

    Checklist

    • [x] Pull request contains a clear definition of changes
    • [x] Tests (either unit, integration, or acceptance) written and passing
    • [x] Relevant documentation produced and/or updated
    opened by mrceperka 7
  • Update PHPCS usage

    Update PHPCS usage

    What does this PR do?

    Updates usage of PHPCS

    • Add config file
    • Fix errors and warnings
    • Update README

    Checklist

    • [x] Pull request contains a clear definition of changes
    • [x] Tests (either unit, integration, or acceptance) written and passing
    • [x] Relevant documentation produced and/or updated
    opened by chadicus 4
  • Update php-coveralls dependency

    Update php-coveralls dependency

    Fixes #34

    What does this PR do?

    Changes satooshi/php-coveralls to php-coveralls/php-coveralls

    Checklist

    • [ ] Pull request contains a clear definition of changes
    • [ ] Tests (either unit, integration, or acceptance) written and passing
    • [ ] Relevant documentation produced and/or updated
    opened by chadicus 4
  • set request method

    set request method

    What does this PR do?

    when converting PSR to oauth2 it does not set $_SERVER[REQUEST_METHOD] but oauth library uses it. I am trying to write tests for this and the mocked request does not have REQUEST_METHOD in $_SERVER so it creates request without request method and oauth2 lib fails

    Checklist

    • [x] Pull request contains a clear definition of changes
    • [x] Tests (either unit, integration, or acceptance) written and passing
    • [ ] Relevant documentation produced and/or updated
    opened by svycka 3
  • Add PHP 7.2 to travis-ci build

    Add PHP 7.2 to travis-ci build

    Fixes #33

    What does this PR do?

    Adds PHP 7.2 to the CI build.

    Checklist

    • [ ] Pull request contains a clear definition of changes
    • [ ] Tests (either unit, integration, or acceptance) written and passing
    • [ ] Relevant documentation produced and/or updated
    opened by chadicus 3
  • Update README

    Update README

    Fixes # .

    What does this PR do?

    Checklist

    • [ ] Pull request contains a clear definition of changes
    • [ ] Tests (either unit, integration, or acceptance) written and passing
    • [ ] Relevant documentation produced and/or updated
    opened by chadicus 3
  • Update copyright

    Update copyright

    Fixes # .

    What does this PR do?

    Checklist

    • [ ] Pull request contains a clear definition of changes
    • [ ] Tests (either unit, integration, or acceptance) written and passing
    • [ ] Relevant documentation produced and/or updated
    opened by chadicus 2
  • Bug 47

    Bug 47

    Fixes #47

    What does this PR do?

    Checklist

    • [ ] Pull request contains a clear definition of changes
    • [ ] Tests (either unit, integration, or acceptance) written and passing
    • [ ] Relevant documentation produced and/or updated
    opened by chadicus 1
  • Unsupported upload of multiple files

    Unsupported upload of multiple files

    Hello, The "convertUploadedFiles" method in the RequestBridge class doesn't support the multiple files uploaded with a same key, as described in the Slim documentation (https://www.slimframework.com/docs/v3/cookbook/uploading-files.html).

    Expected Behavior

    The multiple files in one input or the multiple inputs with the same key are fully supported by the RequestBridge.

    Actual Behavior

    Only one file can be uploaded in an input with a unique key.

    Steps to reproduce the behavior

    Send multiple files using an input named "name[]" in a post request. The following error must appear: Error: Call to a member function getClientFilename() on array

    Thank you.

    opened by mamillastre 1
  • Remove versioneye references

    Remove versioneye references

    Fixes # .

    What does this PR do?

    Checklist

    • [ ] Pull request contains a clear definition of changes
    • [ ] Tests (either unit, integration, or acceptance) written and passing
    • [ ] Relevant documentation produced and/or updated
    opened by chadicus 1
  • Fix typos in README.md

    Fix typos in README.md

    Fixes # .

    What does this PR do?

    Checklist

    • [ ] Pull request contains a clear definition of changes
    • [ ] Tests (either unit, integration, or acceptance) written and passing
    • [ ] Relevant documentation produced and/or updated
    opened by chadicus 1
  • Allow PHP 8 and bump dependencies for Slim 4

    Allow PHP 8 and bump dependencies for Slim 4

    What does this PR do?

    This PR allows the package to be used with Slim 4 / PHP 8, and update dependencies and dev dependencies. It also fixes tests and phpcs configuration.

    I chose to mimic the php dependency of Slim 4 (^7.4 || ^8.0) to be consistent with the framework.

    After this PR, a new major release should be created, and the README should be updated accordingly to reflect the two versions: 3.x for Slim 3 and 4.x for Slim 4

    Happy to discuss and make modifications if necessary

    Relevant PRs in other repositories

    • https://github.com/chadicus/slim-oauth2-routes/pull/47
    • https://github.com/chadicus/slim-oauth2-middleware/pull/63
    • Original work for middleware package: https://github.com/chadicus/slim-oauth2-middleware/pull/48

    Checklist

    • [x] Pull request contains a clear definition of changes
    • [x] Tests (either unit, integration, or acceptance) written and passing
    • [ ] Relevant documentation produced and/or updated -> The README should be updated afterwards
    opened by tchapi 1
  • Check if PHP_AUTH_USER and PHP_AUTH_PW headers are set

    Check if PHP_AUTH_USER and PHP_AUTH_PW headers are set

    Adds test. implementation a bit different from this https://github.com/bshaffer/oauth2-server-php/blob/29afbc04bf6d0df9f5bd84a394edbc87e6c2498f/src/OAuth2/Request.php#L67 does not do magic as in getHeadersFromServer method

    What does this PR do?

    Shows problem

    opened by svycka 0
  • Does not set PHP_AUTH_USER and PHP_AUTH_PW headers

    Does not set PHP_AUTH_USER and PHP_AUTH_PW headers

    @chadicus Can you explain what is this: https://github.com/chadicus/slim-oauth2-http/blob/master/tests/RequestBridgeTest.php#L138-L141 maybe you mistaken and they should be set not from headers but server params like in original implementation here: https://github.com/bshaffer/oauth2-server-php/blob/develop/src/OAuth2/Request.php#L166-L167

    also maybe I don't know something but headers Php-Auth-User and Php-Auth-Pw does not exist in https://github.com/bshaffer/oauth2-server-php. Maybe they are from slim or something?

    opened by svycka 14
Releases(v3.1.8)
Owner
Chad Gray
Creating awesome PHP applications one refactor at a time.
Chad Gray
StartZ oauth2-etsy compatible League of PHP OAuth2

Etsy Provider for OAuth 2.0 Client This package provides Etsy OAuth 2.0 support for the PHP League's OAuth 2.0 Client. Requirements The following vers

StartZ 2 Nov 10, 2022
PSR-7 and PSR-15 HTTP Basic Authentication Middleware

PSR-7 and PSR-15 Basic Auth Middleware This middleware implements HTTP Basic Authentication. It was originally developed for Slim but can be used with

Mika Tuupola 430 Dec 30, 2022
Laravel Passport is an OAuth2 server and API authentication package that is simple and enjoyable to use

Introduction Laravel Passport is an OAuth2 server and API authentication package that is simple and enjoyable to use. Official Documentation Documenta

The Laravel Framework 3.1k Dec 31, 2022
Routes and Middleware for Using OAuth2 Server within a Slim Framework API

Chadicus\Slim\OAuth2 A collection of OAuth2 Server routes, middleware and utilities for use within a Slim 3 Framework API Requirements Chadicus\Slim\O

Chad Gray 126 Oct 8, 2022
documentation for the oauth2-server-php library

OAuth2 Server PHP Documentation This repository hosts the documentation for the oauth2-server-php library. All submissions are welcome! To submit a ch

Brent Shaffer 227 Nov 24, 2022
This is a basic Oauth2 authorization/authentication server implemented using Mezzio.

Mezzio-OAuth2-Authorization-Authentication-Server This is a basic OAuth2 authorization/authentication server implemented using Mezzio. I have found so

null 1 Nov 15, 2022
A plugin for implementing an OAuth2 server in CakePHP 3

OAuth2 Server for CakePHP 3 A plugin for implementing an OAuth2 server in CakePHP 3. Built on top of the PHP League's OAuth2 Server. Currently we supp

uAfrica Technologies (Pty) Ltd 50 Oct 28, 2022
A demo application for running an OAuth2 server

OAuth2 Demo PHP This application is designed to demo the workflow between OAuth2.0 Clients and Servers. If this is your first time here, try experimen

Brent Shaffer 738 Dec 16, 2022
PSR-7 and PSR-15 JWT Authentication Middleware

PSR-7 and PSR-15 JWT Authentication Middleware This middleware implements JSON Web Token Authentication. It was originally developed for Slim but can

Mika Tuupola 782 Dec 18, 2022
An OAuth 2.0 bridge for Laravel and Lumen [DEPRECATED FOR LARAVEL 5.3+]

OAuth 2.0 Server for Laravel (deprecated for Laravel 5.3+) Note: This package is no longer maintaned for Laravel 5.3+ since Laravel now features the P

Luca Degasperi 2.4k Jan 6, 2023
OAuth client integration for Symfony. Supports both OAuth1.0a and OAuth2.

HWIOAuthBundle The HWIOAuthBundle adds support for authenticating users via OAuth1.0a or OAuth2 in Symfony. Note: this bundle adds easy way to impleme

Hardware Info 2.2k Dec 30, 2022
:atom: Social (OAuth1\OAuth2\OpenID\OpenIDConnect) sign with PHP :shipit:

SocialConnect Auth Getting Started :: Documentation :: Demo Open source social sign on PHP. Connect your application(s) with social network(s). Code e

SocialConnect 518 Dec 28, 2022
:atom: Social (OAuth1\OAuth2\OpenID\OpenIDConnect) sign with PHP :shipit:

SocialConnect Auth Getting Started :: Documentation :: Demo Open source social sign on PHP. Connect your application(s) with social network(s). Code e

SocialConnect 458 Apr 1, 2021
:octocat: Socialite is an OAuth2 Authentication tool. It is inspired by laravel/socialite, you can easily use it without Laravel.

Socialite Socialite is an OAuth2 Authentication tool. It is inspired by laravel/socialite, You can easily use it in any PHP project. 中文文档 This tool no

安正超 1.2k Dec 22, 2022
Cliente OAuth2 para Gov.br

Cliente OAuth2 para Gov.br Este pacote fornece suporte OAuth 2.0 para Gov.br usando a biblioteca cliente do League PHP. Requisitos Versões suportadas

Breno Roosevelt 11 Dec 27, 2022
EvaOAuth provides a standard interface for OAuth1.0(a) / OAuth2.0 client authorization, it is easy to integrate with any PHP project by very few lines code.

EvaOAuth EvaOAuth provides a standard interface for OAuth1.0 / OAuth2.0 client authorization, it is easy to integrate with any PHP project by very few

AlloVince 256 Nov 16, 2022
EvaOAuth provides a standard interface for OAuth1.0(a) / OAuth2.0 client authorization, it is easy to integrate with any PHP project by very few lines code.

EvaOAuth EvaOAuth provides a standard interface for OAuth1.0 / OAuth2.0 client authorization, it is easy to integrate with any PHP project by very few

AlloVince 261 Jan 17, 2022
This plugin integrates OAuth2 functionality into Guzzle Bundle

Guzzle Bundle OAuth2 Plugin This plugin integrates OAuth2 functionality into Guzzle Bundle, a bundle for building RESTful web service clients. Prerequ

Vlad Gregurco 12 Oct 30, 2022