The goal of this project is to develop a standards compliant OAuth 2.0 authorization server and resource server.
The framework is provided as a Composer package which can be installed by adding the package to your composer.json file:
{
"require": {
"league/oauth2-server": "2.*"
}
}
The library features 100% unit test code coverage. To run the tests yourself run phpunit
from the project root.
The authorization server is a flexible class and the following core specification grants are implemented:
- authorization code (section 4.1)
- refresh token (section 6)
- client credentials (section 2.3.1)
- password (user credentials) (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.
The resource server allows you to secure your API endpoints by checking for a valid OAuth access token in the request and ensuring the token has the correct scope(s) (i.e. permissions) to access resources.
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.
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.
The wiki has lots of guides on how to use this library, check it out - 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 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.
- Support for JSON web tokens.
- Support for SAML assertions.
The initial code was developed as part of the Linkey project which was funded by JISC under the Access and Identity Management programme.
This code is principally developed and maintained by @alexbilbie.
A list of contributors can be found at https://github.com/php-loep/oauth2-server/contributors.