mirror of
https://github.com/elyby/oauth2-server.git
synced 2024-11-10 07:22:11 +05:30
Merge branch 'release/3.1.2'
Conflicts: README.md
This commit is contained in:
commit
8a2922697f
12
.travis.yml
12
.travis.yml
@ -3,6 +3,16 @@ language: php
|
||||
php:
|
||||
- 5.4
|
||||
- 5.5
|
||||
- 5.6
|
||||
- hhvm
|
||||
|
||||
matrix:
|
||||
allow_failures:
|
||||
- php: hhvm
|
||||
|
||||
before_script: composer install --prefer-source
|
||||
script: phpunit --configuration phpunit.xml.dist
|
||||
script: phpunit --configuration phpunit.xml.dist
|
||||
|
||||
cache:
|
||||
directories:
|
||||
- vendor
|
||||
|
@ -1,5 +1,9 @@
|
||||
# Changelog
|
||||
|
||||
## 3.1.2 (released 2014-02-26)
|
||||
|
||||
* Support Authorization being an environment variable. [See more](http://fortrabbit.com/docs/essentials/quirks-and-constraints#authorization-header)
|
||||
|
||||
## 3.1.1 (released 2013-12-05)
|
||||
|
||||
* Normalize headers when `getallheaders()` is available (Issues #108 and #114)
|
||||
|
15
CONTRIBUTING.md
Normal file
15
CONTRIBUTING.md
Normal file
@ -0,0 +1,15 @@
|
||||
Thanks for contributing to this project.
|
||||
|
||||
|
||||
**Please submit your pull request against the `develop` branch only.**
|
||||
|
||||
|
||||
Please ensure that you run `phpunit` from the project root after you've made any changes.
|
||||
|
||||
If you've added something new please create a new unit test, if you've changed something please update any unit tests as appropritate.
|
||||
|
||||
We're trying to ensure there is **100%** test code coverage (including testing PHP errors and exceptions) so please ensure any new/updated tests cover all of your changes.
|
||||
|
||||
Thank you,
|
||||
|
||||
@alexbilbie
|
34
README.md
34
README.md
@ -1,4 +1,4 @@
|
||||
# league\oauth2-server
|
||||
# PHP OAuth 2.0 Server
|
||||
|
||||
[![Latest Stable Version](https://poser.pugx.org/league/oauth2-server/v/stable.png)](https://packagist.org/packages/league/oauth2-server) [![Coverage Status](https://coveralls.io/repos/php-loep/oauth2-server/badge.png?branch=master)](https://coveralls.io/r/php-loep/oauth2-server?branch=master) [![Total Downloads](https://poser.pugx.org/league/oauth2-server/downloads.png)](https://packagist.org/packages/league/oauth2-server) [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/php-loep/oauth2-server/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
|
||||
|
||||
@ -7,7 +7,7 @@ A standards compliant [OAuth 2.0](http://tools.ietf.org/wg/oauth/draft-ietf-oaut
|
||||
|
||||
## Package Installation
|
||||
|
||||
The framework is provided as a Composer package which can be installed by adding the package to your composer.json file:
|
||||
The framework is provided as a Composer package which can be installed by adding the package to your `composer.json` file:
|
||||
|
||||
```javascript
|
||||
{
|
||||
@ -19,13 +19,18 @@ The framework is provided as a Composer package which can be installed by adding
|
||||
|
||||
### Framework Integrations
|
||||
|
||||
* [Laravel 4 service provider](https://packagist.org/packages/lucadegasperi/oauth2-server-laravel) by @lucadegasperi
|
||||
* [Laravel 4 Eloquent implementation](https://github.com/ScubaClick/scubaclick-oauth2) by @ScubaClick (under development)
|
||||
* [Laravel Service Provider](https://packagist.org/packages/lucadegasperi/oauth2-server-laravel) by @lucadegasperi
|
||||
* [Laravel Eloquent implementation](https://github.com/ScubaClick/scubaclick-oauth2) by @ScubaClick (under development)
|
||||
|
||||
---
|
||||
|
||||
The library features 100% unit test code coverage. To run the tests yourself run `phpunit` from the project root.
|
||||
|
||||
[![Build Status](https://travis-ci.org/thephpleague/oauth2-server.png?branch=master)](https://travis-ci.org/thephpleague/oauth2-server) [master]
|
||||
|
||||
[![Build Status](https://travis-ci.org/thephpleague/oauth2-server.png?branch=develop)](https://travis-ci.org/thephpleague/oauth2-server) [develop]
|
||||
|
||||
|
||||
## Current Features
|
||||
|
||||
### Authorization Server
|
||||
@ -37,7 +42,7 @@ The authorization server is a flexible class and the following core specificatio
|
||||
* client credentials ([section 2.3.1](http://tools.ietf.org/html/rfc6749#section-2.3.1))
|
||||
* password (user credentials) ([section 4.3](http://tools.ietf.org/html/rfc6749#section-4.3))
|
||||
|
||||
An overview of the different OAuth 2.0 grants can be found in the wiki [https://github.com/php-loep/oauth2-server/wiki/Which-OAuth-2.0-grant-should-I-use%3F](https://github.com/php-loep/oauth2-server/wiki/Which-OAuth-2.0-grant-should-I-use%3F).
|
||||
An [overview of the different OAuth 2.0 grants](https://github.com/php-loep/oauth2-server/wiki/Which-OAuth-2.0-grant-should-I-use%3F) can be found in the [wiki].
|
||||
|
||||
### Resource Server
|
||||
|
||||
@ -45,19 +50,19 @@ The resource server allows you to secure your API endpoints by checking for a va
|
||||
|
||||
### Custom grants
|
||||
|
||||
Custom grants can be created easily by implementing an interface. Check out a guide here [https://github.com/php-loep/oauth2-server/wiki/Creating-custom-grants](https://github.com/php-loep/oauth2-server/wiki/Creating-custom-grants).
|
||||
Custom grants can be created easily by implementing an interface. Check out the [custom grant guide](https://github.com/php-loep/oauth2-server/wiki/Creating-custom-grants).
|
||||
|
||||
### PDO driver
|
||||
## Tutorials and Documentation
|
||||
|
||||
If you are using MySQL and want to very quickly implement the library then all of the storage interfaces have been implemented with PDO classes. Check out the guide here [https://github.com/php-loep/oauth2-server/wiki/Using-the-PDO-storage-classes](https://github.com/php-loep/oauth2-server/wiki/Using-the-PDO-storage-classes).
|
||||
* **[Wiki]** - The wiki has lots of guides on how to use this library.
|
||||
|
||||
## Tutorials and documentation
|
||||
* **[Developing an OAuth-2.0 Authorization Server]** - A simple tutorial on how to use the authorization server.
|
||||
|
||||
The wiki has lots of guides on how to use this library, check it out - [https://github.com/php-loep/oauth2-server/wiki](https://github.com/php-loep/oauth2-server/wiki).
|
||||
* **[Securing your API with OAuth 2.0]** - A simple tutorial on how to use the resource server to secure an API server.
|
||||
|
||||
A simple tutorial on how to use the authorization server can be found at [https://github.com/php-loep/oauth2-server/wiki/Developing-an-OAuth-2.0-authorization-server](https://github.com/php-loep/oauth2-server/wiki/Developing-an-OAuth-2.0-authorization-server).
|
||||
|
||||
A simple tutorial on how to use the resource server to secure an API server can be found at [https://github.com/php-loep/oauth2-server/wiki/Securing-your-API-with-OAuth-2.0](https://github.com/php-loep/oauth2-server/wiki/Securing-your-API-with-OAuth-2.0).
|
||||
[Wiki]: https://github.com/php-loep/oauth2-server/wiki
|
||||
[Securing your API with OAuth 2.0]: https://github.com/php-loep/oauth2-server/wiki/Securing-your-API-with-OAuth-2.0
|
||||
[Developing an OAuth-2.0 Authorization Server]: https://github.com/php-loep/oauth2-server/wiki/Developing-an-OAuth-2.0-authorization-server
|
||||
|
||||
## Changelog
|
||||
|
||||
@ -89,5 +94,4 @@ Special thanks to:
|
||||
|
||||
The initial code was developed as part of the [Linkey](http://linkey.blogs.lincoln.ac.uk) project which was funded by [JISC](http://jisc.ac.uk) under the Access and Identity Management programme.
|
||||
|
||||
[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/php-loep/oauth2-server/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
|
||||
|
||||
[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/thephpleague/oauth2-server/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
|
||||
|
@ -2,7 +2,6 @@
|
||||
"name": "league/oauth2-server",
|
||||
"description": "A lightweight and powerful OAuth 2.0 authorization and resource server library with support for all the core specification grants. This library will allow you to secure your API with OAuth and allow your applications users to approve apps that want to access their data from your API.",
|
||||
"version": "3.1.1",
|
||||
"homepage": "https://github.com/php-loep/oauth2-server",
|
||||
"license": "MIT",
|
||||
"require": {
|
||||
"php": ">=5.4.0"
|
||||
@ -38,8 +37,7 @@
|
||||
}
|
||||
],
|
||||
"replace": {
|
||||
"lncd/oauth2": "*",
|
||||
"league/oauth2server": "*"
|
||||
"lncd/oauth2": "*"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
|
@ -185,7 +185,7 @@ class Resource
|
||||
|
||||
$result = $this->storages['session']->validateAccessToken($accessToken);
|
||||
|
||||
if ( ! $result) {
|
||||
if (! $result) {
|
||||
throw new Exception\InvalidAccessTokenException('Access token is not valid');
|
||||
}
|
||||
|
||||
@ -227,7 +227,7 @@ class Resource
|
||||
return false;
|
||||
} elseif (is_array($scopes)) {
|
||||
foreach ($scopes as $scope) {
|
||||
if ( ! in_array($scope, $this->sessionScopes)) {
|
||||
if (! in_array($scope, $this->sessionScopes)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -246,7 +246,15 @@ class Resource
|
||||
*/
|
||||
public function determineAccessToken($headersOnly = false)
|
||||
{
|
||||
if ($header = $this->getRequest()->header('Authorization')) {
|
||||
// Try to get it directly from a header
|
||||
if (! $header = $this->getRequest()->header('Authorization')) {
|
||||
|
||||
// Failing that try getting it from a server variable
|
||||
$header = $this->getRequest()->server('HTTP_AUTHORIZATION');
|
||||
}
|
||||
|
||||
// One of them worked
|
||||
if ($header) {
|
||||
// Check for special case, because cURL sometimes does an
|
||||
// internal second request and doubles the authorization header,
|
||||
// which always resulted in an error.
|
||||
@ -271,5 +279,4 @@ class Resource
|
||||
|
||||
return $accessToken;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -208,7 +208,7 @@ interface SessionInterface
|
||||
* AND refresh_token_expires >= UNIX_TIMESTAMP(NOW()) AND client_id = :clientId
|
||||
* </code>
|
||||
*
|
||||
* @param string $refreshToken The access token
|
||||
* @param string $refreshToken The refresh token
|
||||
* @param string $clientId The client ID
|
||||
* @return int|bool The ID of the access token the refresh token is linked to (or false if invalid)
|
||||
*/
|
||||
|
@ -386,7 +386,6 @@ class Authorization_Server_test extends PHPUnit_Framework_TestCase
|
||||
$this->assertArrayHasKey('expires_in', $v);
|
||||
|
||||
$this->assertEquals($a->getAccessTokenTTL(), $v['expires_in']);
|
||||
$this->assertEquals(time()+$a->getAccessTokenTTL(), $v['expires']);
|
||||
}
|
||||
|
||||
public function test_issueAccessToken()
|
||||
@ -425,7 +424,6 @@ class Authorization_Server_test extends PHPUnit_Framework_TestCase
|
||||
$this->assertArrayHasKey('expires_in', $v);
|
||||
|
||||
$this->assertEquals($a->getAccessTokenTTL(), $v['expires_in']);
|
||||
$this->assertEquals(time()+$a->getAccessTokenTTL(), $v['expires']);
|
||||
}
|
||||
|
||||
public function test_issueAccessToken_customExpiresIn()
|
||||
@ -507,7 +505,6 @@ class Authorization_Server_test extends PHPUnit_Framework_TestCase
|
||||
$this->assertArrayHasKey('expires_in', $v);
|
||||
|
||||
$this->assertEquals($a->getAccessTokenTTL(), $v['expires_in']);
|
||||
$this->assertEquals(time()+$a->getAccessTokenTTL(), $v['expires']);
|
||||
}
|
||||
|
||||
public function tearDown() {
|
||||
|
@ -290,7 +290,6 @@ class Client_Credentials_Grant_Test extends PHPUnit_Framework_TestCase
|
||||
$this->assertArrayHasKey('expires_in', $v);
|
||||
|
||||
$this->assertEquals($a->getAccessTokenTTL(), $v['expires_in']);
|
||||
$this->assertEquals(time()+$a->getAccessTokenTTL(), $v['expires']);
|
||||
}
|
||||
|
||||
function test_issueAccessToken_clientCredentialsGrant()
|
||||
@ -328,7 +327,6 @@ class Client_Credentials_Grant_Test extends PHPUnit_Framework_TestCase
|
||||
$this->assertArrayHasKey('expires_in', $v);
|
||||
|
||||
$this->assertEquals($a->getAccessTokenTTL(), $v['expires_in']);
|
||||
$this->assertEquals(time()+$a->getAccessTokenTTL(), $v['expires']);
|
||||
}
|
||||
|
||||
function test_issueAccessToken_clientCredentialsGrant_customExpiresIn()
|
||||
@ -408,7 +406,6 @@ class Client_Credentials_Grant_Test extends PHPUnit_Framework_TestCase
|
||||
$this->assertArrayHasKey('expires_in', $v);
|
||||
|
||||
$this->assertEquals($a->getAccessTokenTTL(), $v['expires_in']);
|
||||
$this->assertEquals(time()+$a->getAccessTokenTTL(), $v['expires']);
|
||||
}
|
||||
|
||||
}
|
@ -471,7 +471,6 @@ class Password_Grant_Test extends PHPUnit_Framework_TestCase
|
||||
$this->assertArrayHasKey('expires_in', $v);
|
||||
|
||||
$this->assertEquals($a->getAccessTokenTTL(), $v['expires_in']);
|
||||
$this->assertEquals(time()+$a->getAccessTokenTTL(), $v['expires']);
|
||||
}
|
||||
|
||||
function test_issueAccessToken_passwordGrant()
|
||||
@ -516,7 +515,6 @@ class Password_Grant_Test extends PHPUnit_Framework_TestCase
|
||||
$this->assertArrayHasKey('expires_in', $v);
|
||||
|
||||
$this->assertEquals($a->getAccessTokenTTL(), $v['expires_in']);
|
||||
$this->assertEquals(time()+$a->getAccessTokenTTL(), $v['expires']);
|
||||
}
|
||||
|
||||
function test_issueAccessToken_passwordGrant_customExpiresIn()
|
||||
@ -611,7 +609,5 @@ class Password_Grant_Test extends PHPUnit_Framework_TestCase
|
||||
$this->assertArrayHasKey('refresh_token', $v);
|
||||
|
||||
$this->assertEquals($a->getAccessTokenTTL(), $v['expires_in']);
|
||||
$this->assertEquals(time()+$a->getAccessTokenTTL(), $v['expires']);
|
||||
}
|
||||
|
||||
}
|
@ -67,7 +67,6 @@ class Refresh_Token_test extends PHPUnit_Framework_TestCase
|
||||
$this->assertArrayHasKey('refresh_token', $v);
|
||||
|
||||
$this->assertEquals($a->getAccessTokenTTL(), $v['expires_in']);
|
||||
$this->assertEquals(time()+$a->getAccessTokenTTL(), $v['expires']);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -208,7 +207,6 @@ class Refresh_Token_test extends PHPUnit_Framework_TestCase
|
||||
$this->assertArrayHasKey('expires_in', $v);
|
||||
|
||||
$this->assertEquals($a->getAccessTokenTTL(), $v['expires_in']);
|
||||
$this->assertEquals(time()+$a->getAccessTokenTTL(), $v['expires']);
|
||||
}
|
||||
|
||||
public function test_issueAccessToken_refreshTokenGrant()
|
||||
@ -247,7 +245,6 @@ class Refresh_Token_test extends PHPUnit_Framework_TestCase
|
||||
$this->assertArrayHasKey('expires_in', $v);
|
||||
|
||||
$this->assertEquals($a->getAccessTokenTTL(), $v['expires_in']);
|
||||
$this->assertEquals(time()+$a->getAccessTokenTTL(), $v['expires']);
|
||||
}
|
||||
|
||||
public function test_issueAccessToken_refreshTokenGrant_rotateTokens()
|
||||
@ -290,7 +287,6 @@ class Refresh_Token_test extends PHPUnit_Framework_TestCase
|
||||
$this->assertArrayHasKey('refresh_token', $v);
|
||||
|
||||
$this->assertEquals($a->getAccessTokenTTL(), $v['expires_in']);
|
||||
$this->assertEquals(time()+$a->getAccessTokenTTL(), $v['expires']);
|
||||
}
|
||||
|
||||
public function test_issueAccessToken_refreshTokenGrant_customExpiresIn()
|
||||
|
Loading…
Reference in New Issue
Block a user