•  


GitHub - reb3r/oauth2-server-httpfoundation-bridge: Integrate HttpFoundation into your oauth2-server library
Skip to content

reb3r/oauth2-server-httpfoundation-bridge

 
 

Repository files navigation

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 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. v2.2 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 Christian Reber (christian.reber fujitsu com) for more information

Acknowledgements

Very big "Thank you" goes to Brent Shaffer ( https://github.com/bshaffer ) for the original version which I forked.

About

Integrate HttpFoundation into your oauth2-server library

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%
- "漢字路" 한글한자자동변환 서비스는 교육부 고전문헌국역지원사업의 지원으로 구축되었습니다.
- "漢字路" 한글한자자동변환 서비스는 전통문화연구회 "울산대학교한국어처리연구실 옥철영(IT융합전공)교수팀"에서 개발한 한글한자자동변환기를 바탕하여 지속적으로 공동 연구 개발하고 있는 서비스입니다.
- 현재 고유명사(인명, 지명등)을 비롯한 여러 변환오류가 있으며 이를 해결하고자 많은 연구 개발을 진행하고자 하고 있습니다. 이를 인지하시고 다른 곳에서 인용시 한자 변환 결과를 한번 더 검토하시고 사용해 주시기 바랍니다.
- 변환오류 및 건의,문의사항은 juntong@juntong.or.kr로 메일로 보내주시면 감사하겠습니다. .
Copyright ⓒ 2020 By '전통문화연구회(傳統文化硏究會)' All Rights reserved.
 한국   대만   중국   일본