A spec compliant, secure by default PHP OAuth 2.0 Server
Go to file
Ian Littman 27d5c5ed8d
Ensure unvalidated ClientEntity gets throw/emit if they return null
In many cases, we validate client info before pulling from client itself
from the repository, in which case it's safe to assume that you can grab
the client once validation passes. However on implicit/auth code grants
we don't have this guarantee due to non-confidential clients that just
reference the client ID. In those cases the client may supply a client
ID that doesn't exist, and we don't do a validation step before pulling
it from the repo.

The issue with that is that ClientRepository doesn't actually enforce
returning a ClientInterface via typehint, nor does it even suggest an
exception to throw if the client doesn't exist. So in most places we
do an instanceof check after the repository returns and throw/emit an
error event if the client doesn't exist.

This approach ends up being a bit error-prone; we missed one case where
we should've been doing this check: in the access token request on an
auth code grant. We don't do enough validation beforehand to assume that
the incoming request has an accurate client ID, so L96 could absolutely
be a method call on a non-object.

This commit centralizes the return-check-emit-throw logic so it's a
one-liner for wherever we need it, including the access token request
processor for auth code grants.
2019-05-11 14:35:59 -05:00
examples Add optional code challenge check for public clients 2018-08-12 20:06:34 +01:00
src Ensure unvalidated ClientEntity gets throw/emit if they return null 2019-05-11 14:35:59 -05:00
tests Merge latest version of 8 branch 2018-12-19 13:03:10 +00:00
.gitattributes fix .gitattributes 2018-01-03 09:41:39 +01:00
.gitignore Updated .gitignore / .gitattributes files 2016-02-12 17:51:28 +00:00
.scrutinizer.yml Updated .scrutenizer.yml 2016-04-18 12:23:13 +01:00
.styleci.yml Fix StyleCI issues and remove phpdoc order from StyleCI 2018-02-28 20:01:01 +00:00
.travis.yml Update travis to check 8.0.0 branch 2018-05-23 16:39:55 +01:00
CHANGELOG.md Merge latest version of 8 branch 2018-12-19 13:03:10 +00:00
CODE_OF_CONDUCT.md Rename CONDUCT.md to CODE_OF_CONDUCT.md 2018-04-21 22:25:51 +01:00
composer.json Remove paragonie/random_compat 2018-02-26 12:38:31 +00:00
CONTRIBUTING.md Fix #772 - PR should be based on master branch 2017-07-29 17:41:44 +02:00
LICENSE Rename license file 2015-12-03 14:30:37 +01:00
phpstan.neon PHPStan level 7 2018-02-18 21:20:48 +01:00
phpunit.xml.dist Ignore TemplateRenderer method 2016-03-10 17:45:31 +00:00
README.md Change sentence 2018-06-08 11:19:27 +01:00

PHP OAuth 2.0 Server

Latest Version Software License Build Status Coverage Status Quality Score Total Downloads PHPStan

league/oauth2-server is a standards compliant implementation of an OAuth 2.0 authorization server written in PHP which makes working with OAuth 2.0 trivial. You can easily configure an OAuth 2.0 server to protect your API with access tokens, or allow clients to request new access tokens and refresh them.

Out of the box it supports the following grants:

  • Authorization code grant
  • Implicit grant
  • Client credentials grant
  • Resource owner password credentials grant
  • Refresh grant

The following RFCs are implemented:

This library was created by Alex Bilbie. Find him on Twitter at @alexbilbie.

Requirements

The following versions of PHP are supported:

  • PHP 7.0
  • PHP 7.1
  • PHP 7.2

The openssl extension is also required.

All HTTP messages passed to the server should be PSR-7 compliant. This ensures interoperability with other packages and frameworks.

Installation

composer require league/oauth2-server

Documentation

The library documentation can be found at https://oauth2.thephpleague.com. You can contribute to the documentation in the gh-pages branch.

Testing

The library uses PHPUnit for unit tests and PHPStan for static analysis of the code.

vendor/bin/phpunit
vendor/bin/phpstan analyse -l 7 -c phpstan.neon src tests

Continous Integration

We use Travis CI, Scrutinizer, and StyleCI for continuous integration. Check out our configuration files if you'd like to know more.

Community Integrations

Changelog

See the project changelog

Contributing

Contributions are always welcome. Please see CONTRIBUTING.md and CODE_OF_CONDUCT.md for details.

Support

Bugs and feature request are tracked on GitHub.

If you have any questions about OAuth please open a ticket here; please don't email the address below.

Commercial Support

If you would like help implementing this library into your existing platform, or would be interested in OAuth advice or training for you and your team please get in touch with Glynde Labs.

Security

If you discover any security related issues, please email hello@alexbilbie.com instead of using the issue tracker.

License

This package is released under the MIT License. See the bundled LICENSE file for details.

Credits

This code is principally developed and maintained by Andy Millington and Simon Hamp.

Between 2012 and 2017 this library was developed and maintained by Alex Bilbie.

PHP OAuth 2.0 Server is one of many packages provided by The PHP League. To find out more, please visit our website.

Special thanks to all of these awesome contributors.

Additional thanks go to the Mozilla Secure Open Source Fund for funding a security audit of this library.

The initial code was developed as part of the Linkey project which was funded by JISC under the Access and Identity Management programme.