spomky-labs / oauth2-server-exception-manager-bundle
Symfony2 OAuth2 Server Exception Manager Bundle
Requires
Requires (Dev)
- behat/behat: 3.*
- behat/symfony2-extension: *
- symfony/class-loader: ~2.3
- symfony/yaml: ~2.3
This package is not auto-updated.
Last update: 2015-08-17 10:39:37 UTC
README
This bundle adds an exception manager to your OAuth2 Server.
It relies on the OAuth2 Interfaces Project.
The Release Process
The release process is described here.
Prerequisites
This library needs at least PHP 5.4
and Symfony v2.3
.
It has been successfully tested using:
- PHP:
PHP 5.4
toPHP 5.6
,PHP 7
andHHVM
. - Symfony:
v2.3.x
tov2.7.x
.
Installation
The preferred way to install this library is to rely on Composer:
composer require "spomky-labs/oauth2-server-exception-manager-bundle" "~5.0.0"
Enable the bundle
Enable the bundle in the kernel:
<?php // app/AppKernel.php public function registerBundles() { $bundles = array( ... new SpomkyLabs\OAuth2ServerExceptionManagerBundle\SpomkyLabsOAuth2ServerExceptionManagerBundle(), ); }
Configuration
This bundle does not need to be configured, all options have a default value.
Full configuration:
sl_oauth2_exception_manager: realm: 'OAuth2 Server' manager: sl_oauth2_exception_manager.exception_manager.default
How to use
This bundle adds a new service sl_oauth2_exception_manager.manager
.
You do not have anything to do. Let your component do the magic!
If you really want to throw your own exceptions (for example in a custom grant type):
$exception = $this->container->get("sl_oauth2_exception_manager.manager")->getException(ExceptionManagerInterface::BAD_REQUEST, ExceptionManagerInterface::INVALID_GRANT, "Parameter 'foo' is missing", array("bar"=>"baz")); throw $exception;
The first argument of the method getException
indicate the type of exception.
Supported types are:
- ExceptionManagerInterface::AUTHENTICATE
- ExceptionManagerInterface::BAD_REQUEST
- ExceptionManagerInterface::NOT_IMPLEMENTED
- ExceptionManagerInterface::REDIRECT
- ExceptionManagerInterface::INTERNAL_SERVER_ERROR
Supported messages are:
- ExceptionManagerInterface::INVALID_REQUEST
- ExceptionManagerInterface::INVALID_CLIENT
- ExceptionManagerInterface::INVALID_GRANT
- ExceptionManagerInterface::INVALID_SCOPE
- ExceptionManagerInterface::UNAUTHORIZED_CLIENT
- ExceptionManagerInterface::UNSUPPORTED_GRANT_TYPE
- ExceptionManagerInterface::ACCESS_DENIED
- ExceptionManagerInterface::UNSUPPORTED_RESPONSE_TYPE
- ExceptionManagerInterface::SERVER_ERROR
- ExceptionManagerInterface::TEMPORARILY_UNAVAILABLE
You also can define your own messages.
Contributing
Requests for new features, bug fixed and all other ideas to make this library awesome are welcome. Please follow these best practices.
Licence
This library is release under MIT licence.