mirror of
https://github.com/elyby/oauth2-server.git
synced 2024-11-01 16:33:07 +05:30
Merge branch 'refs/heads/master' into develop
Conflicts: .travis.yml README.md
This commit is contained in:
commit
4a71c376b8
3
.gitattributes
vendored
3
.gitattributes
vendored
@ -1,4 +1,5 @@
|
|||||||
tests/ export-ignore
|
tests/ export-ignore
|
||||||
phpunit.xml export-ignore
|
phpunit.xml export-ignore
|
||||||
build.xml export-ignore
|
build.xml export-ignore
|
||||||
test export-ignore
|
test export-ignore
|
||||||
|
.travis.yml export-ignore
|
@ -3,7 +3,7 @@ language: php
|
|||||||
php:
|
php:
|
||||||
- 5.3
|
- 5.3
|
||||||
- 5.4
|
- 5.4
|
||||||
|
- 5.5
|
||||||
|
|
||||||
before_script: composer install --prefer-source
|
before_script: composer install --prefer-source
|
||||||
|
|
||||||
script: phpunit --configuration phpunit.xml.dist
|
script: phpunit --configuration phpunit.xml.dist
|
47
README.md
47
README.md
@ -1,6 +1,6 @@
|
|||||||
# The League of Extraordinary Packages presents: PHP OAuth 2.0 Server
|
# PHP OAuth 2.0 Server
|
||||||
|
|
||||||
The goal of this project is to develop a standards compliant [OAuth 2.0](http://tools.ietf.org/wg/oauth/draft-ietf-oauth-v2/) authorization server and resource server.
|
A standards compliant [OAuth 2.0](http://tools.ietf.org/wg/oauth/draft-ietf-oauth-v2/) authorization server and resource server written in PHP.
|
||||||
|
|
||||||
## Package Installation
|
## Package Installation
|
||||||
|
|
||||||
@ -16,14 +16,14 @@ The framework is provided as a Composer package which can be installed by adding
|
|||||||
|
|
||||||
#### Master branch
|
#### Master branch
|
||||||
|
|
||||||
Latest stable version - [![Latest Stable Version](https://poser.pugx.org/league/oauth2-server/v/stable.png)](https://packagist.org/packages/league/oauth2-server)
|
Latest stable version - [![Latest Stable Version](https://poser.pugx.org/league/oauth2-server/v/stable.png)](https://packagist.org/packages/league/oauth2-server)
|
||||||
Code coverage - [![Coverage Status](https://coveralls.io/repos/php-loep/oauth2-server/badge.png?branch=master)](https://coveralls.io/r/php-loep/oauth2-server?branch=master)
|
Code coverage - [![Coverage Status](https://coveralls.io/repos/php-loep/oauth2-server/badge.png?branch=master)](https://coveralls.io/r/php-loep/oauth2-server?branch=master)
|
||||||
Downloads - [![Total Downloads](https://poser.pugx.org/league/oauth2-server/downloads.png)](https://packagist.org/packages/league/oauth2-server)
|
Downloads - [![Total Downloads](https://poser.pugx.org/league/oauth2-server/downloads.png)](https://packagist.org/packages/league/oauth2-server)
|
||||||
|
|
||||||
#### Develop branch
|
#### Develop branch
|
||||||
|
|
||||||
Latest unstable version - [![Latest Unstable Version](https://poser.pugx.org/league/oauth2-server/v/unstable.png)](https://packagist.org/packages/league/oauth2-server)
|
Latest unstable version - [![Latest Unstable Version](https://poser.pugx.org/league/oauth2-server/v/unstable.png)](https://packagist.org/packages/league/oauth2-server)
|
||||||
Code coverage - [![Coverage Status](https://coveralls.io/repos/php-loep/oauth2-server/badge.png?branch=develop)](https://coveralls.io/r/php-loep/oauth2-server?branch=develop)
|
Code coverage - [![Coverage Status](https://coveralls.io/repos/php-loep/oauth2-server/badge.png?branch=develop)](https://coveralls.io/r/php-loep/oauth2-server?branch=develop)
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@ -58,21 +58,36 @@ If you are using MySQL and want to very quickly implement the library then all o
|
|||||||
|
|
||||||
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).
|
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).
|
||||||
|
|
||||||
A tutorial on how to use the authorization server can be found on the wiki - (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 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 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).
|
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).
|
||||||
|
|
||||||
## Future Goals
|
## Changelog
|
||||||
|
|
||||||
### Authorization Server
|
[See the project releases page](https://github.com/php-loep/oauth2-server/releases)
|
||||||
|
|
||||||
* Support for [JSON web tokens](http://tools.ietf.org/wg/oauth/draft-ietf-oauth-json-web-token/).
|
## Contributing
|
||||||
* Support for [SAML assertions](http://tools.ietf.org/wg/oauth/draft-ietf-oauth-saml2-bearer/).
|
|
||||||
|
|
||||||
---
|
Please see [CONTRIBUTING](https://github.com/php-loep/oauth2-server/blob/master/CONTRIBUTING.md) for details.
|
||||||
|
|
||||||
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.
|
## Support
|
||||||
|
|
||||||
This code is principally developed and maintained by [@alexbilbie](https://twitter.com/alexbilbie).
|
Bugs and feature request are tracked on [GitHub](https://github.com/php-loep/oauth2-server/issues)
|
||||||
|
|
||||||
A list of contributors can be found at [https://github.com/php-loep/oauth2-server/contributors](https://github.com/php-loep/oauth2-server/contributors).
|
## License
|
||||||
|
|
||||||
|
This package is released under the MIT License. See the bundled [LICENSE](https://github.com/php-loep/oauth2-server/blob/master/LICENSE) file for details.
|
||||||
|
|
||||||
|
## Credits
|
||||||
|
|
||||||
|
This code is principally developed and maintained by [Alex Bilbie](https://twitter.com/alexbilbie).
|
||||||
|
|
||||||
|
Special thanks to:
|
||||||
|
|
||||||
|
* [Dan Horrigan](https://github.com/dandoescode)
|
||||||
|
* [Nick Jackson](https://github.com/jacksonj04)
|
||||||
|
* [Michael Gooden](https://github.com/MichaelGooden)
|
||||||
|
* [Phil Sturgeon](https://github.com/philsturgeon)
|
||||||
|
* [and all the other contributors](https://github.com/php-loep/oauth2-server/contributors)
|
||||||
|
|
||||||
|
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.
|
@ -20,19 +20,21 @@ interface ClientInterface
|
|||||||
*
|
*
|
||||||
* <code>
|
* <code>
|
||||||
* # Client ID + redirect URI
|
* # Client ID + redirect URI
|
||||||
* SELECT oauth_clients.id, oauth_clients.secret, oauth_client_endpoints.redirect_uri, oauth_clients.name
|
* SELECT oauth_clients.id, oauth_clients.secret, oauth_client_endpoints.redirect_uri, oauth_clients.name,
|
||||||
|
* oauth_clients.auto_approve
|
||||||
* FROM oauth_clients LEFT JOIN oauth_client_endpoints ON oauth_client_endpoints.client_id = oauth_clients.id
|
* FROM oauth_clients LEFT JOIN oauth_client_endpoints ON oauth_client_endpoints.client_id = oauth_clients.id
|
||||||
* WHERE oauth_clients.id = :clientId AND oauth_client_endpoints.redirect_uri = :redirectUri
|
* WHERE oauth_clients.id = :clientId AND oauth_client_endpoints.redirect_uri = :redirectUri
|
||||||
*
|
*
|
||||||
* # Client ID + client secret
|
* # Client ID + client secret
|
||||||
* SELECT oauth_clients.id, oauth_clients.secret, oauth_clients.name FROM oauth_clients WHERE
|
* SELECT oauth_clients.id, oauth_clients.secret, oauth_clients.name, oauth_clients.auto_approve FROM oauth_clients
|
||||||
* oauth_clients.id = :clientId AND oauth_clients.secret = :clientSecret
|
* WHERE oauth_clients.id = :clientId AND oauth_clients.secret = :clientSecret
|
||||||
*
|
*
|
||||||
* # Client ID + client secret + redirect URI
|
* # Client ID + client secret + redirect URI
|
||||||
* SELECT oauth_clients.id, oauth_clients.secret, oauth_client_endpoints.redirect_uri, oauth_clients.name FROM
|
* SELECT oauth_clients.id, oauth_clients.secret, oauth_client_endpoints.redirect_uri, oauth_clients.name,
|
||||||
* oauth_clients LEFT JOIN oauth_client_endpoints ON oauth_client_endpoints.client_id = oauth_clients.id
|
* oauth_clients.auto_approve FROM oauth_clients LEFT JOIN oauth_client_endpoints
|
||||||
* WHERE oauth_clients.id = :clientId AND oauth_clients.secret = :clientSecret AND
|
* ON oauth_client_endpoints.client_id = oauth_clients.id
|
||||||
* oauth_client_endpoints.redirect_uri = :redirectUri
|
* WHERE oauth_clients.id = :clientId AND oauth_clients.secret = :clientSecret AND
|
||||||
|
* oauth_client_endpoints.redirect_uri = :redirectUri
|
||||||
* </code>
|
* </code>
|
||||||
*
|
*
|
||||||
* Response:
|
* Response:
|
||||||
@ -44,6 +46,7 @@ interface ClientInterface
|
|||||||
* [client secret] => (string) The client secret
|
* [client secret] => (string) The client secret
|
||||||
* [redirect_uri] => (string) The redirect URI used in this request
|
* [redirect_uri] => (string) The redirect URI used in this request
|
||||||
* [name] => (string) The name of the client
|
* [name] => (string) The name of the client
|
||||||
|
* [auto_approve] => (bool) Whether the client should auto approve
|
||||||
* )
|
* )
|
||||||
* </code>
|
* </code>
|
||||||
*
|
*
|
||||||
@ -54,4 +57,4 @@ interface ClientInterface
|
|||||||
* @return bool|array Returns false if the validation fails, array on success
|
* @return bool|array Returns false if the validation fails, array on success
|
||||||
*/
|
*/
|
||||||
public function getClient($clientId, $clientSecret = null, $redirectUri = null, $grantType = null);
|
public function getClient($clientId, $clientSecret = null, $redirectUri = null, $grantType = null);
|
||||||
}
|
}
|
||||||
|
@ -11,17 +11,17 @@ class Client implements ClientInterface
|
|||||||
$db = \ezcDbInstance::get();
|
$db = \ezcDbInstance::get();
|
||||||
|
|
||||||
if ( ! is_null($redirectUri) && is_null($clientSecret)) {
|
if ( ! is_null($redirectUri) && is_null($clientSecret)) {
|
||||||
$stmt = $db->prepare('SELECT oauth_clients.id, oauth_clients.secret, oauth_client_endpoints.redirect_uri, oauth_clients.name FROM oauth_clients LEFT JOIN oauth_client_endpoints ON oauth_client_endpoints.client_id = oauth_clients.id WHERE oauth_clients.id = :clientId AND oauth_client_endpoints.redirect_uri = :redirectUri');
|
$stmt = $db->prepare('SELECT oauth_clients.id, oauth_clients.secret, oauth_client_endpoints.redirect_uri, oauth_clients.name, oauth_clients.auto_approve FROM oauth_clients LEFT JOIN oauth_client_endpoints ON oauth_client_endpoints.client_id = oauth_clients.id WHERE oauth_clients.id = :clientId AND oauth_client_endpoints.redirect_uri = :redirectUri');
|
||||||
$stmt->bindValue(':redirectUri', $redirectUri);
|
$stmt->bindValue(':redirectUri', $redirectUri);
|
||||||
}
|
}
|
||||||
|
|
||||||
elseif ( ! is_null($clientSecret) && is_null($redirectUri)) {
|
elseif ( ! is_null($clientSecret) && is_null($redirectUri)) {
|
||||||
$stmt = $db->prepare('SELECT oauth_clients.id, oauth_clients.secret, oauth_clients.name FROM oauth_clients WHERE oauth_clients.id = :clientId AND oauth_clients.secret = :clientSecret');
|
$stmt = $db->prepare('SELECT oauth_clients.id, oauth_clients.secret, oauth_clients.name, oauth_clients.auto_approve FROM oauth_clients WHERE oauth_clients.id = :clientId AND oauth_clients.secret = :clientSecret');
|
||||||
$stmt->bindValue(':clientSecret', $clientSecret);
|
$stmt->bindValue(':clientSecret', $clientSecret);
|
||||||
}
|
}
|
||||||
|
|
||||||
elseif ( ! is_null($clientSecret) && ! is_null($redirectUri)) {
|
elseif ( ! is_null($clientSecret) && ! is_null($redirectUri)) {
|
||||||
$stmt = $db->prepare('SELECT oauth_clients.id, oauth_clients.secret, oauth_client_endpoints.redirect_uri, oauth_clients.name FROM oauth_clients LEFT JOIN oauth_client_endpoints ON oauth_client_endpoints.client_id = oauth_clients.id WHERE oauth_clients.id = :clientId AND oauth_clients.secret = :clientSecret AND oauth_client_endpoints.redirect_uri = :redirectUri');
|
$stmt = $db->prepare('SELECT oauth_clients.id, oauth_clients.secret, oauth_client_endpoints.redirect_uri, oauth_clients.name, oauth_clients.auto_approve FROM oauth_clients LEFT JOIN oauth_client_endpoints ON oauth_client_endpoints.client_id = oauth_clients.id WHERE oauth_clients.id = :clientId AND oauth_clients.secret = :clientSecret AND oauth_client_endpoints.redirect_uri = :redirectUri');
|
||||||
$stmt->bindValue(':redirectUri', $redirectUri);
|
$stmt->bindValue(':redirectUri', $redirectUri);
|
||||||
$stmt->bindValue(':clientSecret', $clientSecret);
|
$stmt->bindValue(':clientSecret', $clientSecret);
|
||||||
}
|
}
|
||||||
@ -39,7 +39,8 @@ class Client implements ClientInterface
|
|||||||
'client_id' => $row->id,
|
'client_id' => $row->id,
|
||||||
'client_secret' => $row->secret,
|
'client_secret' => $row->secret,
|
||||||
'redirect_uri' => (isset($row->redirect_uri)) ? $row->redirect_uri : null,
|
'redirect_uri' => (isset($row->redirect_uri)) ? $row->redirect_uri : null,
|
||||||
'name' => $row->name
|
'name' => $row->name,
|
||||||
|
'auto_approve' => $row->auto_approve
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user